Skip to main content

A native Python client for the Vertica database.

Project description

# vertica-python

[![PyPI version](https://badge.fury.io/py/vertica-python.png)](http://badge.fury.io/py/vertica-python)

Starting with v0.2.0 python_vertica interface is more consistent with dbapi. One big thing missing is server side cursors/streaming. The old interface is deprecated, but should still be supported.

vertica-python is a native Python adapter for the Vertica (http://www.vertica.com) database.

This package is a Python port of the excellent Vertica Ruby gem (https://github.com/sprsquish/vertica).

vertica-python is currently in a alpha stage; it has been tested for functionality, but does not have a test suite. Please use with caution, and feel free to submit issues and/or pull requests.

vertica-python has been tested with Vertica 6.1.2/7.0.0 and Python 2.6/2.7. Please let me know if it's working on other versions.


## Installation

If you're using pip >= 1.4 and you don't already have pytz installed:

pip install --pre pytz

To install vertica-python with pip:

pip install vertica-python

Source code for vertica-python can be found at:

http://github.com/uber/vertica-python

## Usage

**Buffered** (in-memory) results as list:

```python
from vertica_python import connect

connection = connect({
'host': '127.0.0.1',
'port': 5433,
'user': 'some_user',
'password': 'some_password',
'database': 'a_database'

})

cur = connection.cursor()
cur.execute("SELECT * FROM a_table LIMIT 2")
cur.fetchall()
# [ [1, 'something'], [2, 'something_else'] ]
connection.close()
```


**Buffered** (in-memory) results as dictionary:

```python
cur = connection.cursor('dict')
cur.execute("SELECT * FROM a_table LIMIT 2")
cur.fetchall()
# [ {'id': 1, 'value': 'something'}, {'id': 2, 'value': 'something_else'} ]
connection.close()
```


**Unbuffered** (streaming) results:

```python
def magical_row_handler(row):
print row

cur = connection.cursor(row_handler=magical_row_handler)
cur.execute("SELECT * FROM a_table LIMIT 2", handler=magical_row_handler)
# {'id': 1, 'value': 'something'}
# {'id': 2, 'value': 'something_else'}

connection.close()
```


**Using parameter bindings:

```python
# Using parameter bindings requires psycopg2>=2.5.1 which is not includes with the base vertica_python requirements.

cur = connection.cursor()
cur.execute("SELECT * FROM a_table WHERE a = :propA b = :propB", {'propA': 1, 'propB': 'stringValue'})
cur.fetchall()
# [ [1, 'something'], [2, 'something_else'] ]

connection.close()
```


## License

MIT License, please see `LICENSE` for details.


## Acknowledgements

Many thanks go to the contributors to the Ruby Vertica gem, since they did all of the wrestling with Vertica's protocol and have kept the gem updated. They are:

* [Matt Bauer](http://github.com/mattbauer)
* [Jeff Smick](http://github.com/sprsquish)
* [Willem van Bergen](http://github.com/wvanbergen)
* [Camilo Lopez](http://github.com/camilo)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vertica-python-0.2.0.tar.gz (14.9 kB view details)

Uploaded Source

File details

Details for the file vertica-python-0.2.0.tar.gz.

File metadata

File hashes

Hashes for vertica-python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3df8b8c1d166005b3d7661156705c4ccc5822e0ff2b5a3db6b5abe91415b159a
MD5 998822e9fda248c5fc8b3e2c267d6da8
BLAKE2b-256 108b3ae0107b8925f747d18573d1b6ec74a3e41262886e6d7cf8873ea20729a9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page