Reputation: 1596
How can I connect to Hadoop via Hive ODBC from C# ? Any code sample would be great too. I am not using Azure HDInsight.
Upvotes: 2
Views: 4682
Reputation: 11016
Install the ODBC driver for you hive. And configure it. Eg in the example I have configured the dsn name as horton. Here is the code:
static DataTable GetDataFromHive()
{
OdbcConnection DbConnection = new OdbcConnection("DSN=horton");
try
{
DbConnection.Open();
}
catch (OdbcException ex)
{
Console.WriteLine(ex.Message);
return null;
}
OdbcCommand cmd = DbConnection.CreateCommand();
cmd.CommandText = "SELECT * FROM sample_08 LIMIT 100;";
DbDataReader dr = cmd.ExecuteReader();
var dataTable = new DataTable();
dataTable.Load(dr);
DbConnection.Close();
return dataTable;
}
Upvotes: 2
Reputation: 1596
I tried to answer my own question by posting an article in codeproject.
How to communicate to Hadoop via Hive using .NET/C#
Upvotes: 1