Skip to main content

Usage Sample ''''''''''''

.. code::

   import executor 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_one('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 executor import with_transaction, transaction

   @with_transaction
   def test_transaction():
      insert_func(....)
      update_func(....)


   def test_transaction2():
      with transaction():
          insert_func(....)
          update_func(....)

Release files for sqlx-executor 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlx-executor 1.1.6
File Size Uploaded
sqlx-executor-1.1.6.tar.gz 12.3 kB Details

Release files / sqlx-executor-1.1.6.tar.gz

Download URL sqlx-executor-1.1.6.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
475a11ec758d3df2065c4172847a9511289c950c4f216f5d6035b3a6d267babe
BLAKE2b-256 checksum
How to use checksums
806d1cac4583a90778664edc47d4140139d95ecc799550345a132c029f494ab5
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

1.1.6 This release

1 release file

1.1.5

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

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