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.1

Add package __version__. Minor update for pytest_postgresql 4.0.0.

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
  • add support for psycopg3 connection pool?

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.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

anodb-4.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anodb-4.0.1.tar.gz
  • Upload date:
  • Size: 6.9 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.1.tar.gz
Algorithm Hash digest
SHA256 83a5be3c7592a4cd70cb2f8664f9dc86178a35c6f9c56a997ccc033124791738
MD5 0fa57f765f2c6c88ff0da854a2587052
BLAKE2b-256 18068bb5e079c82c3df1ffb5faf7f28717efa0794de8a5621006d11616586768

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: anodb-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7798a089886fc3ffff42e7861b81aa7d9f5e02ae58da861ec45576a0e01e9206
MD5 03484197e7284ea4e8dd4e1add0dd488
BLAKE2b-256 0109e56bd2aa68bcf0f4b2649e50f0fccdcbdf7732dcc8705d87bd6c364490d6

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