Skip to content

Instantly share code, notes, and snippets.

@narendrans
Last active January 7, 2024 15:35
Show Gist options
  • Save narendrans/a43e25032cdcfd073ca48de4f942c2c6 to your computer and use it in GitHub Desktop.
Save narendrans/a43e25032cdcfd073ca48de4f942c2c6 to your computer and use it in GitHub Desktop.
Dremio C# example using flight sql odbc driver
using System;
using System.Data.Odbc;
class Program
{
static void Main()
{
string connectionString = "DRIVER={Arrow Flight SQL ODBC Driver};host=localhost;UID=dremio;PWD=dremio123;PORT=32010;UseEncryption=false;DisableHostVerification=1;DisableCertificateVerification=1;HandshakeTimeout=100;ROUTING_TAG=testing";
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
try
{
connection.Open();
string query = "SELECT name,kind FROM sys.options limit 10";
using (OdbcCommand command = new OdbcCommand(query, connection))
{
command.CommandTimeout = 50;
//https://learn.microsoft.com/en-us/dotnet/api/system.data.odbc.odbccommand.commandtimeout?view=dotnet-plat-ext-8.0#property-value
using (OdbcDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine($"Name: {reader["name"]}, Kind: {reader["kind"]}");
}
}
else
{
Console.WriteLine("No rows found.");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
@narendrans
Copy link
Author

  1. Create a new project and run the following in the solution folder:

dotnet add package System.Data.Odbc --version 4.8.3

  1. Install Dremio Flight ODBC Driver: https://www.dremio.com/drivers/odbc/
  2. Run the above program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment