The DB-API 2.0 spec should be familiar to you if you’ve used the standard library sqlite3 driver, psycopg2 or the like. Peewee currently relies on a handful of parts:
- Connection.commit
- Connection.execute
- Cursor.description
- Cursor.fetchone
These methods are generally wrapped up in higher-level abstractions and exposed by the , so even if your driver doesn’t do these exactly you can still get a lot of mileage out of peewee. An example is the apsw sqlite driver in the “playhouse” module.
The provides a higher-level API and is responsible for executing queries, creating tables and indexes, and introspecting the database to get lists of tables. The above implementation is the absolute minimum needed, though some features will not work – for best results you will want to additionally add a method for extracting a list of tables and indexes for a table from the database. We’ll pretend that is a lot like MySQL and has special “SHOW” statements:
Other things the database handles that are not covered here include:
- and
quote
, which tell the SQL-generating code how to add parameter placeholders and quote entity names. field_types
for mapping data-types like INT or TEXT to their vendor-specific type names.
Note
If your driver conforms to the DB-API 2.0 spec, there shouldn’t be much work needed to get up and running.