Skip to main content

sql-orm

A simple python ORM (Object relational mapping) which can be used similar to Django ORM and can be easily integrated to any python project.

This ORM can be adapted easily to existing database as well (without even using any migrations). It can also be integrated with both MySQL and PostgreSQL in the same project.

Dependencies

  • Python3

Installation

$pip install sql-orm

Set up

Create a directory named db_models and a file named models.py.

Create models in models.py similar to the properties of the columns used in your database.

Create a config file for connecting to the database.

[POSTGRESQL]
DB_HOST = localhost
DB_PORT = 5432
DB_NAME = dbname
DB_USER = user
DB_PASSWORD = password
DEBUG = True

Set DEBUG = True only if you wish to see the SQL queries.

If you want to do create the tables as well, create a migrate.py file using: https://github.com/shubhamdipt/sql-orm/blob/master/migrate.py

Sample models can be found in the GitHub repository.

New features

  • Support for schema (can be added as an attribute in the models. "public" is the default schema.)

    _schema = "public"

  • Query: get_or_none (similar to get_or_create)

  • Negative indexing support for slicing queryset.

  • For setting any ForeignKey, either assign Model object or just the primary key (both works).

Differences

  • The primary key for every model needs to supplied explicitly.
  • All the models should be in one file called models.py in db_models directory.
  • verbose_name is optional for every field currently.

Missing features / Work in progress

  • JSONField for PostgreSQL.
  • ManyToMany relationship in models.
  • Support for MySQL.
  • Support for makemigrations.

Please feel free to contribute.

Metadata

Release files for sql-orm 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sql-orm 1.2.2
File Size Uploaded
sql-orm-1.2.2.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sql-orm 1.2.2
File Interpreter ABI Platform
sql_orm-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / sql-orm-1.2.2.tar.gz

Download URL sql-orm-1.2.2.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
46d7b27200bdf6335505184394dd27938edb51107ad54f4dd59cbf79872e3e43
BLAKE2b-256 checksum
How to use checksums
1d52c0b9cbe81f714c6437205f3b69433b075b19f1ce548e93a6195fc8320b9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release files / sql_orm-1.2.2-py3-none-any.whl

Download URL sql_orm-1.2.2-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86e688cdb62e6a2dc14b2c8b988a2ed3519de131b61c689da30c0d413de8e6db
BLAKE2b-256 checksum
How to use checksums
994745ac8a944a89aa13ad89a30231a38b59dc254ca65f6c66a425eb47a27040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page