sql-smith


Namesql-smith JSON
Version 1.1.1 PyPI version JSON
download
home_page
Summarysql-smith is an SQL query builder with zero dependencies and a fluent interface.
upload_time2023-05-15 15:24:50
maintainer
docs_urlNone
authorfbraem
requires_python>=3.10,<4.0
licenseMIT
keywords sql-smith query builder querybuilder sql mysql sqlite postgres sqlserver database
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========
sql-smith
=========

**sql-smith** is an SQL query builder with zero dependencies and a fluent interface.

    The sentence above is, beside the name, a copy from the website of the PHP library
    Latitude_, for the simple reason that this Python module is a port of Latitude.

Read the full `documentation <https://fbraem.github.io/sql-smith>`_.

Installation
************

.. code-block:: sh

    $ pip install sql-smith

Quick Start
***********

QueryFactory is a factory to create a **SELECT**, **INSERT**, **UPDATE** or **DELETE** query.
Use the fluent interface of the queries to complete the query.

.. code-block:: python

    from sql_smith import QueryFactory
    from sql_smith.engine import CommonEngine
    from sql_smith.functions import field
    
    factory = QueryFactory(CommonEngine())
    query = factory \
        .select('id', 'username') \
        .from_('users') \
        .where(field('id').eq(5)) \
        .compile()
    
    print(query.sql)  # SELECT "id", "username" FROM "users" WHERE "id" = ?
    print(query.params)  # (5)

When the query is ready, compile it. The return value of compile is a Query class instance
with two properties: sql and params. Use these properties to pass the query to a database.

.. code-block:: python

    import sqlite3
    
    db = sqlite3.connect('test.db')
    cur = db.cursor()

    for row in cur.execute(query.sql, query.params):
        print(row)

Acknowledgment
==============
Big thanks to JetBrains_ to let me use PyCharm for free!

.. _Latitude: https://latitude.shadowhand.com/
.. _JetBrains: https://www.jetbrains.com/pycharm/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sql-smith",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "sql-smith,query,builder,querybuilder,sql,mysql,sqlite,postgres,sqlserver,database",
    "author": "fbraem",
    "author_email": "franky.braem@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e6/23/19691141bd471092760f72bfc5546ad60acdcdf754b8c8d345e17a51ffbf/sql_smith-1.1.1.tar.gz",
    "platform": null,
    "description": "=========\nsql-smith\n=========\n\n**sql-smith** is an SQL query builder with zero dependencies and a fluent interface.\n\n    The sentence above is, beside the name, a copy from the website of the PHP library\n    Latitude_, for the simple reason that this Python module is a port of Latitude.\n\nRead the full `documentation <https://fbraem.github.io/sql-smith>`_.\n\nInstallation\n************\n\n.. code-block:: sh\n\n    $ pip install sql-smith\n\nQuick Start\n***********\n\nQueryFactory is a factory to create a **SELECT**, **INSERT**, **UPDATE** or **DELETE** query.\nUse the fluent interface of the queries to complete the query.\n\n.. code-block:: python\n\n    from sql_smith import QueryFactory\n    from sql_smith.engine import CommonEngine\n    from sql_smith.functions import field\n    \n    factory = QueryFactory(CommonEngine())\n    query = factory \\\n        .select('id', 'username') \\\n        .from_('users') \\\n        .where(field('id').eq(5)) \\\n        .compile()\n    \n    print(query.sql)  # SELECT \"id\", \"username\" FROM \"users\" WHERE \"id\" = ?\n    print(query.params)  # (5)\n\nWhen the query is ready, compile it. The return value of compile is a Query class instance\nwith two properties: sql and params. Use these properties to pass the query to a database.\n\n.. code-block:: python\n\n    import sqlite3\n    \n    db = sqlite3.connect('test.db')\n    cur = db.cursor()\n\n    for row in cur.execute(query.sql, query.params):\n        print(row)\n\nAcknowledgment\n==============\nBig thanks to JetBrains_ to let me use PyCharm for free!\n\n.. _Latitude: https://latitude.shadowhand.com/\n.. _JetBrains: https://www.jetbrains.com/pycharm/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "sql-smith is an SQL query builder with zero dependencies and a fluent interface.",
    "version": "1.1.1",
    "project_urls": null,
    "split_keywords": [
        "sql-smith",
        "query",
        "builder",
        "querybuilder",
        "sql",
        "mysql",
        "sqlite",
        "postgres",
        "sqlserver",
        "database"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6028ddbaef092f0c8dbdd2eaec8391c2d4ab1d3d7013912a1c0151721a4d34d2",
                "md5": "8c6c1c05623ce319fbc668b05ef8919c",
                "sha256": "f092a1816ee7bfd740cd381a38c2d4524e101f580eec0cb8ec6882ee8f90bbed"
            },
            "downloads": -1,
            "filename": "sql_smith-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c6c1c05623ce319fbc668b05ef8919c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 29469,
            "upload_time": "2023-05-15T15:24:48",
            "upload_time_iso_8601": "2023-05-15T15:24:48.201287Z",
            "url": "https://files.pythonhosted.org/packages/60/28/ddbaef092f0c8dbdd2eaec8391c2d4ab1d3d7013912a1c0151721a4d34d2/sql_smith-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e62319691141bd471092760f72bfc5546ad60acdcdf754b8c8d345e17a51ffbf",
                "md5": "d5b02491badecd39b6b1a89d4689eac1",
                "sha256": "5622205e4f8f1815ddb0bd347a0bc6bece507d2fccaa948f867f407dd6cf9c3d"
            },
            "downloads": -1,
            "filename": "sql_smith-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d5b02491badecd39b6b1a89d4689eac1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 13933,
            "upload_time": "2023-05-15T15:24:50",
            "upload_time_iso_8601": "2023-05-15T15:24:50.123553Z",
            "url": "https://files.pythonhosted.org/packages/e6/23/19691141bd471092760f72bfc5546ad60acdcdf754b8c8d345e17a51ffbf/sql_smith-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-15 15:24:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sql-smith"
}
        
Elapsed time: 0.12604s