Skip to main content

Easy to use, light weight ORM

Project description

Installation

To install pydb to your machine, run the following script from the root of your project's directory:

pip3 install pyDBMS

Pydb

Description: Pydb provides users with a light-weight, easy to use ORM(Object Relational Mapping) for multiple DBMS systems. The primary goal is to make communicating between databases as easy as possible using a unified base model type and abstract database interface. Pydb is designed to be easily extended to other languages as needed by the user.

Dependencies

When pydb is installed all libraries that will also be installed through pip. Pydb currently has no external dependencies until non-native databases are supported.

Usage

Models

Users have the ability to create their own custom models and seamlessly add them to their database of choice.

example_model.py

from pyDBMS import Model, Text, Float, Integer
class ExampleModel(Model):
  __table_name__ = 'example_models'
  __primary_keys__ = 'model_id' # alternatively ['model_id']

  model_id = Text()
  other_column = Integer()
  another_column = Float()

Selecting Model Entries From The Database

Users may select entries from the database. They can use filters as seen below:

db = SQLiteDB('example.db')

results1 = db.select(ExampleModel, model_id='uuid(1)')
or
results2 = db.select(ExampleModel, other_column=[100,200], another_column=2.0)

or they can select all the models in the database of the given type with:

db = SQLiteDB('example.db')

all_example_models = db.select(ExamplModel)

Inserting And Updating Entries

Users can insert and update model entries across multiple databases with a uniform interface as seen below

local_db = SQLiteDB('local.db')
remote_db = PostgreSQLDB(host='http://db.example.com/',username='admin',password='password123')

# ************************
# process creating models
# ************************
model1 = ExampleModel(model_id='test_id',other_column=100)

local_db.insert(model1)
# same model can be used to upload to postgres DB
remote_db.insert(model1)

model1['another_column'] = 3.14

#update both db's
local_db.update(model1)
remote_db.update(model1)

Query Existing Databases Info

db = SQLiteDB('/location/for/database')

# list tables and columns

for table in db.tables():
  print(table + ':')
  for column in db.get_columns(table):
    print(column)

How to test the software

Pydb is developed using Test-Driven Development. All the unittests can be run using the following command in the root directory:

python3 -m unittest discover

Known issues

Pydb currently only supports the Sqlite database as the requirements are being elicited.

Getting help

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

Getting involved

If you are interested in contributing fixes or features to MonoGame, please read our CONTRIBUTOR guide first.

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

pyDBMS-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

pyDBMS-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file pyDBMS-0.1.1.tar.gz.

File metadata

  • Download URL: pyDBMS-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for pyDBMS-0.1.1.tar.gz
Algorithm Hash digest
SHA256 73ef4bb8c01332664bd9b8cfb9c3e6436bb10a660d6359c5e9f2008063ed382f
MD5 eda0f0929c9358e17806b734dca6d051
BLAKE2b-256 a30335aa1505237b94c6661c3387289e54ad1b86922455e2f3ba10575a4c2305

See more details on using hashes here.

File details

Details for the file pyDBMS-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyDBMS-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for pyDBMS-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c582f89f1110e6f9d966efd81353f6dab9ba65499759e98034c074b4b3825f5c
MD5 607ce91e3352800808d195dbf3cb9ae5
BLAKE2b-256 294c955fde7c2a36f2b71ac08bc82274e2735fc284e866979bc33bf6ea567e85

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