Python ORM
Project description
zprp-23z-python-orm
Migration engine
Installation
pip install skibidi-orm
Usage
Implementation of schema.py
Primary functionallity of the migration engine is to allow for easy megrations between different versions of the database, so structure of schema file should be defined by proprioetary library using migration engine.
Hovewer we can define example schema file as follows for example purposes:
# schema.py
# ...
class Table(MigrationElement):
def __init__(self) -> None:
self.adapter = SQLite3Adapter()
models = Table.__subclasses__()
if self.__class__ == Table:
for cls in models:
self.adapter.create_table(cls.__dict__["table"])
class Post(Table):
columns = [
SQLite3Typing.Column(
name="post_id",
data_type="INTEGER",
column_constraints=[c.PrimaryKeyConstraint("Post", "post_id")],
),
SQLite3Typing.Column(
name="post_name",
data_type="TEXT",
column_constraints=[c.NotNullConstraint("Post", "post_name")],
),
]
table = SQLite3Typing.Table(name="Post", columns=columns)
SQLite3Config("test_database.db")
Above we defined simple implementation of Table
class which works as a base model for all SQL tables in our databse.
Normally Table
class would be abstracted away by proprietary library, but for the sake of example we defined it here.
When he have defined our schema all interactions of end-user with the migration engine are done through CLI.
skibidi-orm
CLI tool for managing schema creations and migrations in Skibidi ORM.
Usage:
$ skibidi-orm [OPTIONS] COMMAND [ARGS]...
Options:
-s, --schema-file PATH
: Specify an external schema file path--install-completion
: Install completion for the current shell.--show-completion
: Show completion for the current shell, to copy it or customize the installation.--help
: Show this message and exit.
Commands:
go
: Go back (and forward) to specific migration.log
: List all migration revisions with their...migrate
: Used to run migration for current schema...preview-migration
: Preview the migration that will be executed.studio
: Run web UI for CRUD operations on current DB.
skibidi-orm go
Go back (and forward) to specific migration.
Usage:
$ skibidi-orm go [OPTIONS] MIGRATION_ID
Arguments:
MIGRATION_ID
: Migration ID [required]
Options:
--help
: Show this message and exit.
skibidi-orm log
List all migration revisions with their descriptions and ID.
Usage:
$ skibidi-orm log [OPTIONS]
Options:
--help
: Show this message and exit.
skibidi-orm migrate
Used to run migration for current schema file. Can accept an optional message as a description of the migration.
Usage:
$ skibidi-orm migrate [OPTIONS]
Options:
-m, --message TEXT
: Description of migration-d, --direct
: Use --direct to run the migration directly. Without the flag, it will create a python migration file.--help
: Show this message and exit.
skibidi-orm preview-migration
Preview the migration that will be executed.
Usage:
$ skibidi-orm preview-migration [OPTIONS]
Options:
--help
: Show this message and exit.
skibidi-orm studio
Run web UI for CRUD operations on current DB.
Usage:
$ skibidi-orm studio [OPTIONS]
Options:
-s, --schema-file TEXT
: Schema file path--help
: Show this message and exit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file skibidi_orm-0.1.35.tar.gz
.
File metadata
- Download URL: skibidi_orm-0.1.35.tar.gz
- Upload date:
- Size: 731.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.15.4 CPython/3.10.12 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f2928ed8e112665539343b7db74362d73139473bf7556deea836bf2541694a0 |
|
MD5 | 66f46b996c6ebf8d9d6e6887a996cd21 |
|
BLAKE2b-256 | 735bd477d30e583742bf8bb7adb6eabb671f8cd9b97f153b9ce53f9890f81d61 |
File details
Details for the file skibidi_orm-0.1.35-py3-none-any.whl
.
File metadata
- Download URL: skibidi_orm-0.1.35-py3-none-any.whl
- Upload date:
- Size: 754.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.15.4 CPython/3.10.12 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e90a1ce2a1e85fa3584f35fe470d1abf01c2e2644b6215e391af5b0544086a4 |
|
MD5 | ae590b15c64ed98541f178f69c7009c6 |
|
BLAKE2b-256 | 93073b555d7728d5330c9a2fbdf99f8dcc7c506572dfc5d81d76803a71cc9809 |