Usage Sample ''''''''''''
.. code::
import sqlexecutorx as db
if __name__ == '__main__':
db.init('test.db', driver='sqlite3', debug=True)
# or
db.init("postgres://user:password@127.0.0.1:5432/testdb", driver='psycopg2', pool_size=5, debug=True)
# or
db.init(host='127.0.0.1', port='5432', user='xxx', password='xxx', database='testdb', driver='psycopg2')
# if driver is 'pymysql' or 'mysql.connector' of MySQL, the select_key is 'SELECT LAST_INSERT_ID()'
select_key = "SELECT currval('person_id_seq')"
id = db.save(select_key, 'INSERT INTO person(name, age) VALUES(%s,%s)', 'wangwu', 38)
persons = db.select('select id, name, age from person')
# result:
# (3, 'zhangsan', 15)
# (4, 'lisi', 26)
# (5, 'wangwu', 38)
# (6, 'zhaoliu', 45)
persons = db.select_first('select id, name, age from person where name = %s', 'zhangsan')
# result:
# (3, 'zhangsan', 15)
args = [
('李四', 55),
('王五', 35),
]
db.batch_execute('INSERT INTO person(name,age) VALUES(%s,%s)', *args)
db.close()
Transaction ''''''''''''
.. code::
from sqlexecutorx import trans
@trans
def test_transaction():
insert_func(....)
update_func(....)
def test_transaction2():
with trans():
insert_func(....)
update_func(....)
If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
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
Metadata
Release files for SQLExecutorX 2.0.2
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 |
|---|---|---|---|---|
| sqlexecutorx-2.0.2.tar.gz | 16.7 kB | Without provenance | Details for sqlexecutorx-2.0.2.tar.gz |
Release files / sqlexecutorx-2.0.2.tar.gz
| Download URL | sqlexecutorx-2.0.2.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73241c4b729b7a6f727e41cb0e7e0452c992d838dd52f27272426125af3b82d7
|
|
BLAKE2b-256 checksum How to use checksums |
fac0e2bd408af6198ea5d6cf7e6b81c1a72947b0ac523951daa4b2379efffccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.18
|
Security for SQLExecutorX 2.0.2
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.