Skip to main content

A Records like database API that works with Aurora Serverless Data API

Project description

Camus

Camus is a raw SQL library enabling an ease integration with the new Aurora Serverless Data API. It is a fork of the powerful Records library.

Camus Aurora Execution

Instalation

The recommended installation method is pipenv:

$ pipenv install camus

Basic Usage

First you need to have an Aurora cluster ARN and a Secret ARN. If don't have one yet, just follow the Data API Getting Started Guide.

With that in hands, let's drop some query to our database:

import camus

db = camus.Database(
    resource_arn="arn:aws:rds:us-east-1:123456789012:cluster:your-cluster-name",
    secret_arn="arn:aws:secretsmanager:us-east-1:123456789012:secret:your-secret-name-ByH87J",
    dbname="mydb",
)

rows = db.query("SELECT * FROM users")

You can grab one row at time (like in Records library)

>>> rows[0]
<camus.Record at 0x109bfbd30>

Or iterate over them:

 for r in rows:
     print(r.name, r.email)

Like mentioned before, Camus is a fork of the Records library, so almost all access pattern are equal:

  row.email
  row['email']
  row[3]

Other options include rows.as_dict() and rows.as_dict(ordered=True)

Transactions

Data API transactions are supported by Camus:

with db.transaction() as txid:
    db.query("INSERT INTO users (name, email) VALUES (:name, :email)", name="Rafael", email="rafael@email.com")
    db.query("UPDATE posts SET title = :title WHERE id = :id", title="New Title", id=999)

If any exception is raised when executing any of the queries, a rollback is performed automatically.

That's all folks

Thanks for the awesome @kennethreitz for providing his knowledge on the excelent Records library and all the talks he has given over the years!

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

camus-0.4.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

camus-0.4.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file camus-0.4.0.tar.gz.

File metadata

  • Download URL: camus-0.4.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for camus-0.4.0.tar.gz
Algorithm Hash digest
SHA256 37062179ad5045a87e21fbf2d663504719d4b4a9b73a0553d1d8af374fc5d19c
MD5 2c35e4a87ab3f5fe9695a023102c7889
BLAKE2b-256 f6f43aeaa16812aa8d09e941bffdeb31e7b24ca91d37aaa72cfe7eb21ec3377f

See more details on using hashes here.

File details

Details for the file camus-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: camus-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for camus-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ecfb5523a4327996531ac311f4375abe2aa33f6fe3536991400878a316c61be
MD5 2c46cc1255ef10ba710ffeceb573bd7e
BLAKE2b-256 923f2bdb2ac6d21e9e1e4c58655da137d4d4bb2330cef6e1709a054ad0b0848e

See more details on using hashes here.

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