Skip to main content

Convenient Wrapper around AioSQL and a Database Connection

Project description

AnoDB

Convenient Wrapper around aiosql and a Database Connection.

Description

This class creates a persistent database connection and imports SQL queries from a file.

If the connection is broken, a new connection is attempted.

Compared do aiosql, the point is not to need to pass a connection as an argument on each call: The DB class embeds both connection and query methods.

Example

Install the module with pip install anodb or whatever method you like. Once available, you can use it:

import anodb
db = anodb.DB('sqlite3', 'test.db', 'test.sql')

db.do_some_insert(key=1, val='hello')
db.do_some_update(key=1, val='world')
print("data", db.do_some_select(key=1))
db.commit()

db.close()

With file test.sql containing something like:

-- name: do_some_select
SELECT * FROM Stuff WHERE key = :key;

-- name: do_some_insert!
INSERT INTO Stuff(key, val) VALUES (:key, :val);

-- name: do_some_update!
UPDATE Stuff SET val = :val WHERE key = :key;

Versions

Sources are available on GitHub.

4.0

Add psycopg 3 support, and make it the default for Postgres.

3.0

Package as a simple module. Use simpler setup.cfg packaging. Include tests in package. Add coverage test and make test coverage reach 100%.

2.2

Setup explicit logger instead of relying on default.

2.1

Make cursor() reconnect if needed.

Add automatic reconnection tests.

2.0

Swith from AnoSQL to AioSQL.

1.3

Make options accept different types.

Make queries optional, and allow to load from files or strings.

1.2

Add options string parameter to constructor.

1.1

Add **conn_options parameter to constructor.

Add cursor() method.

1.0

Initial release.

TODO

  • add support for other drivers? eg. pg8000, pygresql

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anodb-4.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

anodb-4.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file anodb-4.0.0.tar.gz.

File metadata

  • Download URL: anodb-4.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for anodb-4.0.0.tar.gz
Algorithm Hash digest
SHA256 56a6ec453be3a09473764a09b89a1cbadc34e9bf8089e42c3eede827c99cc464
MD5 3e84ad20868e07c27e55ee69ce0ca97a
BLAKE2b-256 adba046fcc246a37f7840ac21a5142e43a01ffd902b4e1ed23ee3f6db66b7632

See more details on using hashes here.

Provenance

File details

Details for the file anodb-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: anodb-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for anodb-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 256a0ac741e51be013ba4cac759ab8a7263983148e55f7ce8f97b30556d89c78
MD5 651ed8ae799cbb7d360494f2f866fe3e
BLAKE2b-256 667810bbc5d7ab92ed7742dd0ee4a8dcf033f92e950911cc4e9b2db5b1930c31

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page