Skip to main content

Traducteur is a simple database manager using pydantic models. Currently only supports mongodb.

Reason this release was yanked:

Bug in manager code

Project description

Traducteur

Traducteur is a pydantic model based database manager. It currently only supports mongodb with SQL support on the way.

Requirements

  • python >= 3.8 with:
    • pymongo >= 4.0.1
    • pydantic >= 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_DATABASE'] = 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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traducteur-0.2.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file traducteur-0.2.1.tar.gz.

File metadata

  • Download URL: traducteur-0.2.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for traducteur-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ad8f08f6f6c4cc61d5662b17754c8e692777e5de9101791a4bdb640c40ccabbf
MD5 efe5c69587986f4cdf2a025470bfad8d
BLAKE2b-256 758d0fe077c35a7636337e73df5ae404fce8dd96cde82f1f533d3d2f4b7b17ae

See more details on using hashes here.

File details

Details for the file traducteur-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: traducteur-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for traducteur-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbcb3a9548af3a267305dc16fc5f9e70a60ae6d5e9a0d28d04c60c70ca173108
MD5 393c1ba1881e456fc81fe9e015202a2b
BLAKE2b-256 cc2152e24d6821f1f99e4367924d017388e322dd87e23365058c1653df74401d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page