sqlx-executor


Namesqlx-executor JSON
Version 1.1.6 PyPI version JSON
download
home_pagehttps://gitee.com/summry/sql-executor
SummaryA simple thread safe sql executor for Python with connection pool. Support MySQL, PostgreSQL, SQLite etc.
upload_time2024-04-25 08:12:52
maintainerNone
docs_urlNone
authorsummy
requires_python>=3.6
licenseNone
keywords sql mysql postgresql sqlite database python rdb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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(....)



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitee.com/summry/sql-executor",
    "name": "sqlx-executor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "SQL, MySQL, PostgreSQL, SQLite, Database, Python, RDB",
    "author": "summy",
    "author_email": "xiazhongbiao@126.com",
    "download_url": "https://files.pythonhosted.org/packages/80/6d/1cac4583a90778664edc47d4140139d95ecc799550345a132c029f494ab5/sqlx-executor-1.1.6.tar.gz",
    "platform": null,
    "description": "Usage Sample\n''''''''''''\n\n.. code::\n\n       import executor as db\n\n       if __name__ == '__main__':\n          db.init('test.db', driver='sqlite3', debug=True)\n\n          # or\n          db.init(\"postgres://user:password@127.0.0.1:5432/testdb\", driver='psycopg2', pool_size=5, debug=True)\n\n          # or\n          db.init(host='127.0.0.1', port='5432', user='xxx', password='xxx', database='testdb', driver='psycopg2')\n\n          # if driver is 'pymysql' or 'mysql.connector' of MySQL, the select_key is 'SELECT LAST_INSERT_ID()'\n          select_key = \"SELECT currval('person_id_seq')\"\n\n          id = db.save(select_key, 'INSERT INTO person(name, age) VALUES(%s,%s)', 'wangwu', 38)\n\n          persons = db.select('select id, name, age from person')\n          # result:\n          # (3, 'zhangsan', 15)\n          # (4, 'lisi', 26)\n          # (5, 'wangwu', 38)\n          # (6, 'zhaoliu', 45)\n\n          persons = db.select_one('select id, name, age from person where name = %s', 'zhangsan')\n          # result:\n          # (3, 'zhangsan', 15)\n\n          args = [\n           ('\u674e\u56db', 55),\n           ('\u738b\u4e94', 35),\n          ]\n          db.batch_execute('INSERT INTO person(name,age) VALUES(%s,%s)', *args)\n\n          db.close()\n\nTransaction\n''''''''''''\n\n.. code::\n\n       from executor import with_transaction, transaction\n\n       @with_transaction\n       def test_transaction():\n          insert_func(....)\n          update_func(....)\n\n\n       def test_transaction2():\n          with transaction():\n              insert_func(....)\n              update_func(....)\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simple thread safe sql executor for Python with connection pool. Support MySQL, PostgreSQL, SQLite etc.",
    "version": "1.1.6",
    "project_urls": {
        "Homepage": "https://gitee.com/summry/sql-executor"
    },
    "split_keywords": [
        "sql",
        " mysql",
        " postgresql",
        " sqlite",
        " database",
        " python",
        " rdb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "806d1cac4583a90778664edc47d4140139d95ecc799550345a132c029f494ab5",
                "md5": "2859fb071592c38ff47a820b3f82814d",
                "sha256": "475a11ec758d3df2065c4172847a9511289c950c4f216f5d6035b3a6d267babe"
            },
            "downloads": -1,
            "filename": "sqlx-executor-1.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "2859fb071592c38ff47a820b3f82814d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12286,
            "upload_time": "2024-04-25T08:12:52",
            "upload_time_iso_8601": "2024-04-25T08:12:52.709370Z",
            "url": "https://files.pythonhosted.org/packages/80/6d/1cac4583a90778664edc47d4140139d95ecc799550345a132c029f494ab5/sqlx-executor-1.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 08:12:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sqlx-executor"
}
        
Elapsed time: 0.22897s