Programming Python Client Applications
In order to use Python with Vertica, you must either install the Vertica Python Client (see Python Client Documentation), or install the pyodbc module and a Vertica ODBC driver on the machine where Python is installed. See Python Prerequisites.
Python on Linux
Most Linux distributions come with Python preinstalled. If you want a more recent version, you can download and build it from the source code, though sometimes RPMs are also available. See the Python Web site and click an individual release for details. See also Python documentation.
To determine the Python version on your Linux operating systems, type the following at a command prompt:
# python -V
The system returns the version; for example:
Python 3.3.4
Python on Windows
Python is not required to run natively on Windows operating systems, so it is not preinstalled. The ActiveState Web site distributes a free Windows installer for Python called ActivePython.
If you need installation instructions for Windows, see Using Python on Windows at python.org. Python on Windows at diveintopython.org provides installation instructions for both the ActivePython and python.org packages.
Python and Unicode
When you are using Python, be sure that all of your components are using the same unicode text encoding. By default, the DSN Parameter ColumnsAsChar causes the ODBC driver to report CHAR and VARCHAR values as SQL_WCHAR. The driver returns these values to the driver manager in the encoding expected by the driver manager, as controlled by the DriverManagerEncoding parameter in vertica.ini. Similarly, your Python application must use the encoding expected by the driver manager. If any of these components use different encodings, your output can become garbled.
The Vertica Python Client
Vertica has a native Python client you can use to communicate with your Vertica database.
Before you can connect to Vertica using Python, you need to download the Python Client. See the Vertica Python Client Documentation, for download and installation instructions.
Using pyodbc and Vertica
Before you can connect to Vertica using pyodbc, you need to download the pyodbc module, which communicates with iODBC/unixODBC driver on UNIX operating systems and the ODBC Driver Manager for Windows operating systems.
The pyodbc module is an open source , MIT-licensed Python module, letting you use ODBC to connect to almost any database from Windows, Linux, Mac OS/X, and other operating systems.
Vertica supports multiple versions of pyodbc. See Python Prerequisites for additional details.
Download the source distribution from the pyodbc Web site, unpack it and build it. Note that you need the unixODBC development package (in addition to the regular build tools) to build pyodbc. For example, on RedHat/CentOS run: yum install unixODBC-devel
, and on Ubuntu run:sudo apt-get install unixodbc-dev
. See the pyodbc wiki for detailed instructions.