Skip to main content

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 PgSQLX: https://pypi.org/project/pgsqlx

If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx

If you wanted simultaneously support MySQL and PostgreSQL, may be you need BatisX: https://pypi.org/project/batisx

Release files for SQLORMX 0.6.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 SQLORMX 0.6.2
File Size Uploaded
sqlormx-0.6.2.tar.gz 10.9 kB Details

Release files / sqlormx-0.6.2.tar.gz

Download URL sqlormx-0.6.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0f03a83bd3e1b71af4af4d9d6502fcfd772014d9f4d4837f92658d06127871ff
BLAKE2b-256 checksum
How to use checksums
4f9977f7b1546e515c28b72db270c36a1687e693a79fe8d9d4ddc332a4fbd34d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.6.2 This release

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.1

1 release file

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