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 pydb

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 pydb 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.0.tar.gz (4.0 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.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyDBMS-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 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.0.tar.gz
Algorithm Hash digest
SHA256 4c4e0204ba6fdc45c1ef7664d81906e451e31653880b12049d4f66e0516fc89c
MD5 b4534c54dfffc24a4187f2cdf8409ee4
BLAKE2b-256 d58f240f17cea48549775e379ef1fcc64e29ccaa99fd05a6b2018ae170f94ec4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyDBMS-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10618b253f5402fac0bc95f5b2b1328d13c5979483f3dbecd2e2934e95cc151a
MD5 1e4016ccc70f72511a784f64f31952ca
BLAKE2b-256 21a28045f55f42b727ce2cb00edf07fc4195762c89a877c6a7a0381e43c5ba68

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