A easy,single table ORM framework for python. Support MySQL, PostgreSQL, SQLite etc.
Project description
Usage Sample ''''''''''''
.. code:: python
from sqlormx import Model, db
from dataclasses import dataclass
@dataclass
class Person(Model):
__table__ = 'person'
id: int = None
name: str = None
age: int = None
if __name__ == '__main__':
db.init('test.db', driver='sqlite3', show_sql=True, debug=True)
db.init_db("postgres://user:password@127.0.0.1:5432/testdb", driver='psycopg2', pool_size=5)
db.init_db(host='127.0.0.1', port='3306', user='xxx', password='xxx', database='test', pool_size=5, show_sql=True)
effected_rowcount = Person.insert(name='tianqi', age=77)
persons = Person.query(name='tianqi')
# select id, name, age from person where name = :name
# result:
# {'id': 7, 'name': 'tianqi', 'age': 77}
persons = Person.query(name__eq='zhangsan')
# select id, name, age from person where name = :name
# result:
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
Transaction '''''''''''
.. code:: python
from sqlormx import trans
@trans
def test_transaction():
insert_func(....)
update_func(....)
def test_transaction2():
with trans():
insert_func(....)
update_func(....)
If you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx
If you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx
If you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx
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
sqlormx-0.5.0.tar.gz
(11.1 kB
view details)
File details
Details for the file sqlormx-0.5.0.tar.gz
.
File metadata
- Download URL: sqlormx-0.5.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bcc9d5015747c9127dd86415e63cfae9e7f8a16fceb90d9d2b0c2720058c0c1 |
|
MD5 | 64daff955a8708fa38d0230bcc684bce |
|
BLAKE2b-256 | dd51724fc829839ca1decf7c48d22828d1f487bb5e86bac7ca91c92ce2bd323b |