Last active
January 7, 2024 15:35
-
-
Save narendrans/a43e25032cdcfd073ca48de4f942c2c6 to your computer and use it in GitHub Desktop.
Dremio C# example using flight sql odbc driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dotnet add package System.Data.Odbc --version 4.8.3