Skip to main content

Python class decorator that creates a database representation of a class and vice versa, a lightweight ORM.

Project description

Database Models

Python class decorator that creates a database representation of a class and vice versa, a lightweight ORM. setup.py provided for installation, uses psycopg 3 rather than 2 for the better context manager support and type hinting.

Recommended Import Setup

import databasemodels as dbm
from databasemodels.datatypes import *

This allows you to use bare datatypes such as INTEGER, or complex datatypes such as PrimaryKey.

Features

All basic types and pseudo-types implemented are all capital, whereas type modifiers and constructed types like enums are capital camel case.

Currently, implemented types/pseudo-types include:

EnumType
INTEGER
SERIAL
REAL
TEXT
TIMESTAMP
TIMESTAMP_WITH_TIMEZONE
DATE
TIME
BOOL
VARCHAR
CHAR
NUMERIC

Currently, implemented constraints include:

ForeignKey
PrimaryKey
Unique
NotNull

Models have a "mutate" context manager which allows you to modify the model safely while reverting the changes if an error is raised.

Planned Features

  • Interval type
  • Additional SQL parameter to createTable
  • Full documentation across all the module
  • Implementation of all types listed here.
  • Higher unittest coverage
  • Higher customizability with table creation and other database operations

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

databasemodels-1.8.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

databasemodels-1.8.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file databasemodels-1.8.0.tar.gz.

File metadata

  • Download URL: databasemodels-1.8.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for databasemodels-1.8.0.tar.gz
Algorithm Hash digest
SHA256 4c948d6d62f3cb0853291af0767a590aa3dba1fcd9b251f9ac7823346cdd124d
MD5 66dc7b0f520f59fd689c6a2c11150524
BLAKE2b-256 767081d44e039b5977f86c347270c736703ac3f48f900debc0fd5c726e2c5e0a

See more details on using hashes here.

File details

Details for the file databasemodels-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: databasemodels-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for databasemodels-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85845a0b93040a78b8ec49eb9c334c2570bd7ee070464d1eb09815e0b773810e
MD5 47530d2e72e683b9025b7c841070a01e
BLAKE2b-256 149aabbf0dd9b5c17806f2adf453a919097d8f4d9a44a48cab2e61730dd7e5a5

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