FireboltNetSDK 1.7.0
dotnet add package FireboltNetSDK --version 1.7.0
NuGet\Install-Package FireboltNetSDK -Version 1.7.0
<PackageReference Include="FireboltNetSDK" Version="1.7.0" />
<PackageVersion Include="FireboltNetSDK" Version="1.7.0" />
<PackageReference Include="FireboltNetSDK" />
paket add FireboltNetSDK --version 1.7.0
#r "nuget: FireboltNetSDK, 1.7.0"
#addin nuget:?package=FireboltNetSDK&version=1.7.0
#tool nuget:?package=FireboltNetSDK&version=1.7.0
firebolt-net-sdk
This is an implementation of .NET 6 Core driver for Firebolt in a form of a DbConnection class. Supports all latest .NET frameworks and all platforms.
This project is developed under Visual Studio 2022. Earlier versions of Visual Studio are not supported.
Installing the Package
Here is a FireboltNetSDK NuGet page.
- Install using .NET CLI
dotnet add package FireboltNetSDK
- Install using Visual Studio UI
Tools
>NuGet Package Manager
>Manage NuGet Packages for Solution
and search forFirebolt
- Install using Package Manager Console:
PM> Install-Package FireboltNetSDK
Examples
Following examples demonstrate how to connect and interact with Firebolt database using this driver:
Creating a connection string
// Name of your Firebolt account
string account = "my_firebolt_account";
// Client credentials, that you want to use to connect
string clientId = "my_client_id";
string clientSecret = "my_client_secret";
// Name of database and engine to connect to (Optional)
string database = "my_database_name";
string engine = "my_engine_name";
// Construct a connection string using defined parameter
string conn_string = $"account={account};clientid={clientId};clientsecret={clientSecret};database={database};engine={engine}";
Opening and closing a connection
using FireboltDotNetSdk.Client;
// Create a new connection using generated connection string
using var conn = new FireboltConnection(conn_string);
// Open a connection
conn.Open();
// Execute SQL, fetch data, ...
// Close the connection after all operations are done
conn.Close();
Executing a SQL command that does not return result
// First you would need to create a command
var command = conn.CreateCommand();
// ... and set the SQL query
command.CommandText = "CREATE DATABASE IF NOT EXISTS MY_DB";
// Execute a SQL query and get a DB reader
command.ExecuteNonQuery();
// Close the connection after all operations are done
conn.Close();
Executing a SQL command that returns a result
// First you would need to create a command
var command = conn.CreateCommand();
// ... and set the SQL query
command.CommandText = "SELECT * FROM my_table";
// Execute a SQL query and get a DB reader
DbDataReader reader = command.ExecuteReader();
// Optionally you can check whether the result set has rows
Console.WriteLine($"Has rows: {reader.HasRows}");
// Discover the result metadata
int n = reader.FieldCount();
for (int i = 0; i < n; i++)
{
Type type = reader.GetFieldType();
string name = reader.GetName();
}
// Iterate over the rows and get values
while (reader.Read())
{
for (int i = 0; i < n; i++)
{
Console.WriteLine($"{reader.GetName(i)}:{reader.GetFieldType(i)}={reader.GetValue(i)}");
}
}
Executing a command with SET parameter
var tz = conn.CreateCommand();
tz.CommandText = "SET time_zone=America/New_York";
tz.ExecuteNonQuery();
tz.CommandText = "SELECT '2000-01-01 12:00:00.123456 Europe/Berlin'::timestamptz as t";
DbDataReader tzr = tz.ExecuteReader();
if (tzr.Read())
{
// 2000-01-01 06:00:00.123456-05
Console.WriteLine(tzr.GetDateTime(0));
}
Server-side Asynchronous Query Execution
Firebolt supports server-side asynchronous query execution, allowing queries to run in the background while you retrieve results later. This is particularly useful for long-running queries, as it eliminates the need to maintain a persistent connection to the server while waiting for execution to complete.
⚠ Note: This is different from .NET's asynchronous programming model. Firebolt's server-side async execution means that the query runs independently on the server, while .NET async/await handles non-blocking execution on the client side.
Execute an Asynchronous Query
Executing a query asynchronously means the database will start processing it in the background. Instead of returning data immediately, the response contains a query token, which can be used later (even in a new connection) to check the query status or retrieve results.
FireboltCommand command = (FireboltCommand)conn.CreateCommand();
command.CommandText = "INSERT INTO large_table SELECT * FROM source_table";
// Execute the query asynchronously on the server
command.ExecuteServerSideAsyncNonQuery();
// Alternatively, use .NET's async/await to avoid blocking the client thread
await command.ExecuteServerSideAsyncNonQueryAsync();
// Store the async query token for later use
string token = command.AsyncToken;
Check the Status of an Asynchronous Query
You can check if the query is still running or if it has finished executing.
IsServerSideAsyncQueryRunning(token)
returnstrue
if the query is still in progress andfalse
if it has finished.IsServerSideAsyncQuerySuccessful(token)
returns:true
if the query completed successfullyfalse
if the query failednull
if the query is still running
using FireboltConnection conn = new FireboltConnection(conn_string);
conn.Open();
// Check if the query is still running
bool isRunning = conn.IsServerSideAsyncQueryRunning(token);
// Check if the query completed successfully (returns null if it's still running)
bool? isSuccessful = conn.IsServerSideAsyncQuerySuccessful(token);
or use .NET asynchronous eqivalents
// Check if the query is still running
bool isRunning = await conn.IsServerSideAsyncQueryRunningAsync(token);
// Check if the query completed successfully (returns null if it's still running)
bool? isSuccessful = await conn.IsServerSideAsyncQuerySuccessfulAsync(token);
Cancel an Asynchronous Query
If an asynchronous query is no longer needed, you can cancel it before execution completes.
using FireboltConnection conn = new FireboltConnection(conn_string);
conn.Open();
// Cancel the async query
bool cancelled = conn.CancelServerSideAsyncQuery(token);
or do so asynchronously
bool cancelled = await conn.CancelServerSideAsyncQueryAsync(token);
This approach ensures that long-running queries do not block your application while allowing you to monitor, manage, and cancel them as needed.
Server-side Prepared Statement Execution
Firebolt supports server-side prepared statement execution, allowing better safety when using client provided inputs, not constructing the query client-side.
Prerequisites
To make use of server-side prepared statements, you need to provide the following parameter in your connection string:
preparedStatementParamStyle=FbNumeric
This makes any prepared statement constructed from the connection to use the FbNumeric
parameter style, which is required for server-side prepared statements.
⚠ Note: Using this parameter, normal prepared statements will not work, so you need to use server-side prepared statements only.
Other than this parameter, the API is the same, except for the command text.
var command = (FireboltCommand)conn.CreateCommand();
command.CommandText = "SELECT * FROM my_table WHERE id = $1";
command.Parameters.AddWithValue("$1", 123);
command.Prepare();
// Execute the query as any other command
using var reader = command.ExecuteReader();
Prepared Statement Parameter Style
The preparedStatementParamStyle
parameter in the connection string can take the following values:
Native
(@paramName) - default: Uses the native parameter style, which is compatible with client-side prepared statements.FbNumeric
($number): Uses Firebolt's numeric parameter style, which is required for server-side prepared statements.
Query result streaming
Firebolt supports query result streaming, allowing you to retrieve large datasets in a memory-efficient manner. This is particularly useful for queries that return a significant amount of data, as it avoids loading the entire result set into memory at once.
Executing a Streaming Query
To execute a query that returns a large result set, you can use the ExecuteStreamedQuery
method or it's asynchronous equivalent ExecuteStreamedQueryAsync
. This method allows you to stream the results directly from the server without loading them all into memory at once.
FireboltCommand command = (FireboltCommand)conn.CreateCommand();
command.CommandText = "SELECT * FROM large_table";
// Execute the query asynchronously on the server
using var reader = command.ExecuteStreamedQuery();
// or use the asynchronous version
using var reader = await command.ExecuteStreamedQueryAsync();
// Iterate over the streamed results in the same way as with a regular DbDataReader
while (await reader.ReadAsync())
{
for (int i = 0; i < reader.FieldCount; i++)
{
Console.WriteLine($"{reader.GetName(i)}: {reader.GetValue(i)}");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.WebUtilities (>= 2.2.0)
- Newtonsoft.Json (>= 13.0.1)
- NodaTime (>= 3.1.6)
- Portable.BouncyCastle (>= 1.9.0)
- System.Text.Encodings.Web (>= 4.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.0 | 667 | 6/4/2025 |
1.6.1 | 8,816 | 4/28/2025 |
1.6.0 | 17,353 | 3/13/2025 |
1.5.0 | 32,752 | 12/19/2024 |
1.4.0 | 7,882 | 12/4/2024 |
1.3.5 | 1,094 | 11/21/2024 |
1.3.4 | 34,495 | 9/25/2024 |
1.3.3 | 114 | 9/24/2024 |
1.3.2 | 4,518 | 9/9/2024 |
1.3.1 | 3,225 | 8/12/2024 |
1.3.0 | 3,134 | 7/10/2024 |
1.2.0 | 5,213 | 6/6/2024 |
1.1.2 | 11,390 | 5/22/2024 |
1.1.1 | 117 | 5/14/2024 |
1.1.0 | 144 | 4/30/2024 |
1.0.0 | 146 | 2/5/2024 |
1.0.0-alpha | 199 | 11/3/2023 |
0.2.0 | 276 | 3/3/2023 |
0.1.0 | 289 | 1/20/2023 |
0.0.1 | 339 | 8/19/2022 |
Initial release of a Firebolt .NET sdk. Supported features
- Authentication
- SQL Query execution
- SET statement support