A Records like database API that works with Aurora Serverless Data API
The recommended installation method is
$ pipenv install camus
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 <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
Other options include
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="firstname.lastname@example.org") 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!
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size camus-0.3.0-py3-none-any.whl (5.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size camus-0.3.0.tar.gz (4.8 kB)||File type Source||Python version None||Upload date||Hashes View hashes|