HiveSQL for Python developers

Use the following code to connect to HiveSQL using Python:

import pypyodbc
connection = pypyodbc.connect('Driver={ODBC Driver 13 for SQL Server};'
cursor = connection.cursor() 
# do whatever you want with the retrieved data

Remember you need to have ODBC drivers installed on your computer.

How to install the Microsoft ODBC Driver for SQL Server on Linux and macOS

On Debian 9

sudo curl > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17

Optional for bcp and sqlcmd

sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile
echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
source ~/.bashrc

Optional for unixODBC development headers

sudo apt-get install unixodbc-dev

For more details on how to install Microsoft SQL ODBC drivers, you can read this post published by @geekgirl

Last updated