No project description provided
Project description
Welcome to s3sqlite-db
This is an extension to encode/databases that allows using sqlite database with AWS S3. Main purpose for this is use with AWS Lambda, to download sqlite db to Lambda on db connect and upload back on disconnect.
Installation
$ pip install s3sqlite-db
Usage
You can use S3Database as async context manager:
S3_BUCKET = 'my-bucket'
S3_KEY = 'database.sqlite'
DATABASE_URL = f's3sqlite://{S3_BUCKET}/{S3_KEY}'
async with S3Database(DATABASE_URL) as db:
query = table.select()
db.fetch_all(query)
or with async framework like FastAPI:
from fastapi import FastAPI
app = FastAPI()
database = S3Database(DATABASE_URL)
@app.on_event("startup")
async def startup():
await database.connect()
@app.on_event("shutdown")
async def shutdown():
await database.disconnect()
Configuration
By default if remote database was modified, exception is raised, but ignote_conflicts=True
argument can be specified, to force overwrite.
async with S3Database(DATABASE_URL, ignote_conflicts=True) as db:
...
Also you can specify a path to download local copy of db. This can be useful when working locally (not on AWS Lambda), or when whorking with several sqlite databaases at the same time.
async with S3Database(DATABASE_URL, local_path='/path/to/db.sqlite') as db:
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file s3sqlite-db-0.1.2.tar.gz
.
File metadata
- Download URL: s3sqlite-db-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d5d9fddfc9e56a1167b934efa3dca3ab7da75582413acef8e71e8bfd57f8582 |
|
MD5 | 9f90b9ad85b1b0aacaed6a818e56127a |
|
BLAKE2b-256 | 0a80d2e12e9d693a0c56b4bbb96205be28636f87287bf0f467f44570913f6e6a |
File details
Details for the file s3sqlite_db-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: s3sqlite_db-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60da68a8035b055aacc60a009a1f3e17fab7b5e20860a532f0e0fcb7aa2a0979 |
|
MD5 | f28394bc746c5387f2442e4f6f172d99 |
|
BLAKE2b-256 | 2c362dfca9d3e4fa872f22d60f28ed55113f3865d001305875e115c0e59df9ac |