# 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};'
                              'Server=vip.hivesql.io;'
                              'Database=DBHive;'
                              'uid=[your_hivesql_account];'
                              'pwd=[your_hivesql_password]')
cursor = connection.cursor() 
SQLCommand = ("YOUR SQL QUERY”)
cursor.execute(SQLCommand)
# do whatever you want with the retrieved data
connection.close()
```

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 https://ift.tt/2OlWDWn > /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](https://steemit.com/utopian-io/@geekgirl/making-sql-queries-to-steemsql-com-with-python-scripts-on-macos) published by @geekgirl


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hivesql.io/tutorials/hivesql-for-python-developers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
