Traducteur is a simple database manager using pydantic models. Currently only supports mongodb.
Project description
Traducteur
Traducteur is a pydantic model based database manager. It currently only supports mongodb.
Requirements
python >= 3.8with:pymongo >= 4.0.1pydantic >= 1.9.0
Example usage
'''
Set a connection string and database name in the environment.
Preferably using a .env file.
'''
import os
CON_STR = 'mongodb://root:example@localhost:27017/'
DB_NAME = 'traducteur'
os.environ['TRADUCTEUR_CONNECTION_STR'] = CON_STR
os.environ['TRADUCTEUR_DB_NAME'] = DB_NAME
'''
Import the base model for the database you are using.
'''
from traducteur import BaseMongoModel
'''
Make a model using the base model.
'''
class User(BaseMongoModel):
username: str
fname: str
lname: str
email: str
'''
Easily create, save, update and delete the model
'''
user = User(
username='johndoe',
fname='John',
lname='Doe',
email='john.doe@mail.com'
)
# saving the model
user = user.save()
# saving also updates the model
user.lname = 'Doe updated'
user = user.save()
# save the user id and set user to None for the GET example
user_id = user.id
user = None
# getting a model by its ID from the database
user = User.get(user_id)
print(user.dict())
# deleting a model from the database
deleted_user = user.delete()
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
traducteur-0.1.0.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traducteur-0.1.0.tar.gz.
File metadata
- Download URL: traducteur-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d19f12d9444cc91843e53c9e281bc520789478e16f44e16b2967112038c9471b
|
|
| MD5 |
1684d70576da546a69131acbcd1099a1
|
|
| BLAKE2b-256 |
e0aec2526883b5ec8f40f3be0021e21ef444abd339d8b1c39ed0e919f66a6e88
|
File details
Details for the file traducteur-0.1.0-py3-none-any.whl.
File metadata
- Download URL: traducteur-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f472f5691b790e281af907fabe139a4a2f4a8be467c1ea33d7ca2246b1b54d61
|
|
| MD5 |
82baffa4c650989b1aa813e6a19a3313
|
|
| BLAKE2b-256 |
c18774bcfb6904c6a18f4d73bbfb575c232c70a97daec54edcf85c234128b1ab
|