Object database for Python
Newt DB, the amphibious database
Work with your data as ordinary Python objects in memory. PostgreSQL keeps it safe, indexes it, and answers search queries from inside or outside your application.
pip install newt.db
Why Newt DB
The ease of objects, the reach of SQL
Newt DB sits between your Python code and PostgreSQL. Object access stays natural, while every saved object also becomes queryable data.
Objects in memory
Read and change ordinary Python objects. Data move in and out of memory as needed, so a database can grow well beyond the size of a single Python process.
Indexed in PostgreSQL
Every object state is stored as JSON beside the native pickle. PostgreSQL indexes that JSON, so search runs close to the data and stays fast.
Objects or raw rows
Ask for application objects, or ask for plain data. Newt DB returns whichever form suits the job, including counts, joins and reports from other tools.
Mature foundations
ZODB supplies transparent persistence. RelStorage moves it into PostgreSQL. Newt DB adds the JSON layer and the search API without hiding either project.
How it works
Two mature projects, one database
Newt DB does not replace ZODB or RelStorage. It adds a searchable JSON view of the same records, then gives you helpers for querying it.
Because the JSON view is lossy, Newt DB keeps the native pickle as the source of truth for loading objects. The JSON copy is read only, and that is what makes it safe to index and query from anywhere.
Quick start
From pip to a committed object
You need a PostgreSQL server, version 9.5 or later. A local install is enough to begin; a hosted server is a sensible choice for production.
-
Install the package
Newt DB is published on PyPI and installs with pip.
pip install newt.db -
Open a connection
The default database is fine for a first run. A connection string works when you need a dedicated database and user.
import newt.db connection = newt.db.connection('') root = connection.root -
Add and commit an object
Objects are added to the root, or to a container below it. Nothing is written to PostgreSQL until you commit.
root.first = newt.db.Object(name='My first object') root.first.child = newt.db.Object(name='First child') connection.commit()
Documentation
Explore the manual
Start with the guide, then move into a topic or jump straight to the API.
Build with the project
Read the source, ask a question on the mailing list, or report a bug. The community page has every route into the project.