dbapi 0.1.0-alpha.6
dbapi: ^0.1.0-alpha.6 copied to clipboard
A standardized interface abstracting database interaction, targeting both SQL and noSQL.
A standardized interface abstracting database interaction, targeting both SQL and noSQL.
IMPORTANT: this project is in heavy active development. APIs are likely to change without notice in backward-incompatible ways.
It's heavily inspired by Python's DB API 2.0, with a few, crucial differences:
- operations are instances of the
Operation
class, as opposed to SQL strings - all methods are asynchronous and should return Futures
- the API surface is simplified
Project Goal #
Provide a shared interface to simplify the development of database-agnostic ORMs and query engines.
Features #
This package tries to target a subset of feature that could realistically be implemented by both a SQL and noSQL database.
For this reason, many SQL feature that are unlikely to be available in a noSQL database are excluded, most notably: joins, aggregated query, expression and subqueries.
Future version may gradually add some of these features.
Currently, the API supports the following operations and features:
- Query
- Insert
- Delete
- Upsert
- Schema Definition:
- Add Collection
- Remove Collection
- Rename Collection
- Add Property
- Remove Property
- Rename Property
- Transactions (connection-level, no save points/nesting)
- Reporting of supported features
- Cursor management
- Comprehensive test suite that can be run against individual implementations
We also include (as separate packages) an SQLite backend and an IndexedDB package (in progress).
Getting started #
Users of this package will fall in two categories, those using the API to create ORMs and query builders, and those who wish to add support for a new Database backend
Using the API #
Thinking of implementing an ORM? Your code needs to use the [Connection]
and [Cursor] APIs. You'll need to create the right Operation
based on your models and [Query]. Looking at the test_suite will give you a good idea of how to perform each operation.
Implement a new Backend #
You can probably go a long way but just implementing the base interfaces provided by this package - but it's highly recommended that you follow the instructions on the dbapi_test_suite docs.
API stability #
This project is under active development and the API is likely to change. In particular we expect that the Operation APIs may change as we discover gaps.
Version 0.x.y are to be considered experimental and breaking changes between them are both possible and likely.
Additional information #
The test_suite is integral part of the API contract. If your database supports a feature but tests can pass you should document it clearly (and let us know, we might need to tweak the APIs!)
Contribution #
Contribution welcome, especially in the form of feedback on the API.