Python Driver for Phoenix
The Python Driver for Apache Phoenix implements the Python DB 2.0 API to access Phoenix via the Phoenix Query Server. The driver is tested with Python 2.7 and 3.5-3.8. This code was originally called Python Phoenixdb and was graciously donated by its authors to the Apache Phoenix project.
All future development of the project is being done in Apache Phoenix.
The latest release is always available from PyPI, and can be installed by pip/pip3 as usual.
pip3 install --user phoenixdb
You can build phoenixdb from the official source release, or you can use the latest development version from the soure repository. The pythondb source lives in the python-phoenixdb direcory of the python-queryserver repository.
$ cd python-phoenixdb # (Only when building from the git repo) $ pip install -r requirements.txt $ python setup.py install
import phoenixdb import phoenixdb.cursor database_url = 'http://localhost:8765/' conn = phoenixdb.connect(database_url, autocommit=True) cursor = conn.cursor() cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username VARCHAR)") cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin')) cursor.execute("SELECT * FROM users") print(cursor.fetchall()) cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor) cursor.execute("SELECT * FROM users WHERE id=1") print(cursor.fetchone()['USERNAME'])
- None presently known.