Usage Sample ''''''''''''
.. code:: python
from orm import Model, db
from typing import List, Tuple, Mapping
class Person(Model):
__pk__ = 'id'
__table__ = 'person'
def __init__(self, id: int = None, name: str = None, age: int = None):
self.id = id
self.name = name
self.age = age
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 orm import with_transaction, transaction
@with_transaction
def test_transaction():
insert_func(....)
update_func(....)
def test_transaction2():
with transaction():
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/sqlx-exec
Metadata
Release files for sqlx-orm 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlx-orm-0.0.7.tar.gz | 11.1 kB | Without provenance | Details for sqlx-orm-0.0.7.tar.gz |
Release files / sqlx-orm-0.0.7.tar.gz
| Download URL | sqlx-orm-0.0.7.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eabcb284c3f70ff3b403e27e0ff5a8dc49f1c1ec5f7c9774942c8813bf8930b1
|
|
BLAKE2b-256 checksum How to use checksums |
341290f013d76ceaee9fbafcd543344b744f515a6e749065706f157f3769b47e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.18
|
Security for sqlx-orm 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.