Before you install a driver: install RethinkDB first.
Looking for another language? See the complete list of client drivers for RethinkDB.
From version 1.14, the Python driver for RethinkDB supports Python 2 and 3. Version 1.13 and older support Python 2 only.
Install the driver with pip. Using a virtual environment is the recommended way to install Python packages so start by creating a virtual environment to use:
# Python 2
$ sudo pip install virtualenv && virtualenv ./venv
# Python 3
$ python3 -m venv ./venv
Then use the pip
binary from your virtual environment to install the RethinkDB driver:
$ source venv/bin/activate
$ pip install rethinkdb
You can use the drivers from Python like this:
$ python
from rethinkdb import r
r.connect('localhost', 28015).repl()
r.db('test').table_create('tv_shows').run()
r.table('tv_shows').insert({ 'name': 'Star Trek TNG' }).run()
Note: RethinkDB connection objects are not thread-safe. It’s recommended that applications open a separate connection per thread, or establish a connection pool.
The RethinkDB Python driver includes support for asynchronous connections using both Tornado and Twisted. Read the asynchronous connections documentation for more information.
Move on to the ten-minute guide and learn how to use RethinkDB.