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

PyDBMS

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.2.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.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyDBMS-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0ee83be3f17b4f323e31686a07724a507f6b7651fb3a497517141a7ec9d0cdd9
MD5 12fde5cdf66ce00131dd959aeee48dc5
BLAKE2b-256 41a38e9c97c934f5b0cf5510962dfe8d5e6f92523d560a50a3f85e8d3c6d9900

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyDBMS-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87343418fce4dc4c4ed79761075b69391a02c414a0001bd3acf648413aaff4c5
MD5 d0668ebad131d0bae95bfac4254798a1
BLAKE2b-256 0bb40384e4775281cff72c7cd881c01615b1760daf85afde44a9e2af4a8462f8

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