sql-helper


Namesql-helper JSON
Version 0.0.21 PyPI version JSON
download
home_pagehttps://github.com/kenjyco/sql-helper
SummaryHelper funcs and tools for working with SQL in mysql, postgresql, and more
upload_time2024-12-02 19:10:18
maintainerNone
docs_urlNone
authorKen
requires_pythonNone
licenseMIT
keywords sql data database cli command-line sqlalchemy mysql postgresql sqlite helper kenjyco
VCS
bugtrack_url
requirements bg-helper click cryptography psycopg2-binary settings-helper pymysql pymysql pymysql sqlalchemy sqlalchemy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            About
-----

This is meant to be a simple way to explore a postgresql/mysql/sqlite
database and get data out (super light wrapper to SQLAlchemy).

Connect with DB url in the following formats:

-  ``postgresql://someuser:somepassword@somehost[:someport]/somedatabase``
-  ``mysql://someuser:somepassword@somehost[:someport]/somedatabase``
-  ``sqlite:///somedb.db``

..

   Note: This package uses ``pymysql`` driver for connecting to mysql.
   Urls that start with ``mysql://`` will automatically be changed to
   use ``mysql+pymysql://``.

Dependencies
------------

pg_config for postgresql
^^^^^^^^^^^^^^^^^^^^^^^^

   Ensure the ``pg_config`` executable is on the system

::

   sudo apt-get install -y libpq-dev

or

::

   brew install postgresql

cryptography package
^^^^^^^^^^^^^^^^^^^^

If using Python 3.6, be sure to update pip to **at least version 19.3**
(default pip is 18.1) so that the pre-compiled wheel for
``cryptography`` can be used. Otherwise, you will need to install the
`rust compiler <https://www.rust-lang.org>`__ so that the
``cryptography`` dependency can be built
(``curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y``)

pymysql package
^^^^^^^^^^^^^^^

According to https://nvd.nist.gov/vuln/detail/CVE-2024-36039, pymysql
versions below 1.1.1 are vulnerable to SQL injection. Version 1.1.1 is
only available for Python 3.7+ (final version for Python 3.6 is 1.0.2;
final working version for Python 3.5 is 0.9.3).

Install
-------

::

   pip3 install sql-helper

Usage
-----

::

   In [1]: from sql_helper import SQL

   In [2]: sql = SQL('postgresql://someuser:somepassword@somehost/somedatabase')

   In [3]: table_names = sql.get_tables()

   In [4]: results = sql.execute('SELECT ...')

Extra
-----

`Redshift <https://aws.amazon.com/redshift/>`__
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Install ``sqlalchemy-redshift`` wherever you installed ``sql-helper``

::

   venv/bin/pip3 install sqlalchemy-redshift

Connect with DB url in the following format:

-  ``redshift+psycopg2://someuser:somepassword@somehost/somedatabase``

Test matrix
-----------

   Tested with the following python versions and dependency combinations
   against postgres 13 and mysql 8.0 docker containers.

::

   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.1
   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.24
   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.1
   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.24
   venv_py3.5.10_psycopg2-binary2.8_pymysql0.10.1_sqlalchemy1.3.1
   venv_py3.5.10_psycopg2-binary2.8_pymysql0.10.1_sqlalchemy1.3.24
   venv_py3.5.10_psycopg2-binary2.8_pymysql0.9.3_sqlalchemy1.3.1
   venv_py3.5.10_psycopg2-binary2.8_pymysql0.9.3_sqlalchemy1.3.24

   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.4.54
   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.4.54
   venv_py3.6.15_psycopg2-binary2.8.6_pymysql1.0.2_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.8.6_pymysql1.0.2_sqlalchemy1.4.54
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.10.1_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.10.1_sqlalchemy1.4.54
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.9.3_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.9.3_sqlalchemy1.4.54
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql1.0.2_sqlalchemy1.3.24
   venv_py3.6.15_psycopg2-binary2.9.8_pymysql1.0.2_sqlalchemy1.4.54

   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2
   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36

   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24
   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54
   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.31
   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kenjyco/sql-helper",
    "name": "sql-helper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "sql, data, database, cli, command-line, sqlalchemy, mysql, postgresql, sqlite, helper, kenjyco",
    "author": "Ken",
    "author_email": "kenjyco@gmail.com",
    "download_url": "https://github.com/kenjyco/sql-helper/tarball/v0.0.21",
    "platform": null,
    "description": "About\n-----\n\nThis is meant to be a simple way to explore a postgresql/mysql/sqlite\ndatabase and get data out (super light wrapper to SQLAlchemy).\n\nConnect with DB url in the following formats:\n\n-  ``postgresql://someuser:somepassword@somehost[:someport]/somedatabase``\n-  ``mysql://someuser:somepassword@somehost[:someport]/somedatabase``\n-  ``sqlite:///somedb.db``\n\n..\n\n   Note: This package uses ``pymysql`` driver for connecting to mysql.\n   Urls that start with ``mysql://`` will automatically be changed to\n   use ``mysql+pymysql://``.\n\nDependencies\n------------\n\npg_config for postgresql\n^^^^^^^^^^^^^^^^^^^^^^^^\n\n   Ensure the ``pg_config`` executable is on the system\n\n::\n\n   sudo apt-get install -y libpq-dev\n\nor\n\n::\n\n   brew install postgresql\n\ncryptography package\n^^^^^^^^^^^^^^^^^^^^\n\nIf using Python 3.6, be sure to update pip to **at least version 19.3**\n(default pip is 18.1) so that the pre-compiled wheel for\n``cryptography`` can be used. Otherwise, you will need to install the\n`rust compiler <https://www.rust-lang.org>`__ so that the\n``cryptography`` dependency can be built\n(``curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y``)\n\npymysql package\n^^^^^^^^^^^^^^^\n\nAccording to https://nvd.nist.gov/vuln/detail/CVE-2024-36039, pymysql\nversions below 1.1.1 are vulnerable to SQL injection. Version 1.1.1 is\nonly available for Python 3.7+ (final version for Python 3.6 is 1.0.2;\nfinal working version for Python 3.5 is 0.9.3).\n\nInstall\n-------\n\n::\n\n   pip3 install sql-helper\n\nUsage\n-----\n\n::\n\n   In [1]: from sql_helper import SQL\n\n   In [2]: sql = SQL('postgresql://someuser:somepassword@somehost/somedatabase')\n\n   In [3]: table_names = sql.get_tables()\n\n   In [4]: results = sql.execute('SELECT ...')\n\nExtra\n-----\n\n`Redshift <https://aws.amazon.com/redshift/>`__\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nInstall ``sqlalchemy-redshift`` wherever you installed ``sql-helper``\n\n::\n\n   venv/bin/pip3 install sqlalchemy-redshift\n\nConnect with DB url in the following format:\n\n-  ``redshift+psycopg2://someuser:somepassword@somehost/somedatabase``\n\nTest matrix\n-----------\n\n   Tested with the following python versions and dependency combinations\n   against postgres 13 and mysql 8.0 docker containers.\n\n::\n\n   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.1\n   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.24\n   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.1\n   venv_py3.5.10_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.24\n   venv_py3.5.10_psycopg2-binary2.8_pymysql0.10.1_sqlalchemy1.3.1\n   venv_py3.5.10_psycopg2-binary2.8_pymysql0.10.1_sqlalchemy1.3.24\n   venv_py3.5.10_psycopg2-binary2.8_pymysql0.9.3_sqlalchemy1.3.1\n   venv_py3.5.10_psycopg2-binary2.8_pymysql0.9.3_sqlalchemy1.3.24\n\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.10.1_sqlalchemy1.4.54\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql0.9.3_sqlalchemy1.4.54\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql1.0.2_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.8.6_pymysql1.0.2_sqlalchemy1.4.54\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.10.1_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.10.1_sqlalchemy1.4.54\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.9.3_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql0.9.3_sqlalchemy1.4.54\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql1.0.2_sqlalchemy1.3.24\n   venv_py3.6.15_psycopg2-binary2.9.8_pymysql1.0.2_sqlalchemy1.4.54\n\n   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.7.17_psycopg2-binary2.9.9_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.8.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.9.20_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.10.15_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.11.10_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.2\n   venv_py3.12.7_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.3.24\n   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy1.4.54\n   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.31\n   venv_py3.13.0_psycopg2-binary2.9.10_pymysql1.1.1_sqlalchemy2.0.36\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Helper funcs and tools for working with SQL in mysql, postgresql, and more",
    "version": "0.0.21",
    "project_urls": {
        "Download": "https://github.com/kenjyco/sql-helper/tarball/v0.0.21",
        "Homepage": "https://github.com/kenjyco/sql-helper"
    },
    "split_keywords": [
        "sql",
        " data",
        " database",
        " cli",
        " command-line",
        " sqlalchemy",
        " mysql",
        " postgresql",
        " sqlite",
        " helper",
        " kenjyco"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47876c5f838fa509774d4ef5f88af0080471ff44ff70d2e0af850a486b473f70",
                "md5": "9eef47d6cead5f7aa4e2a7a02029a2b4",
                "sha256": "db1c68f5dd14eb4e13cede4605304e8ed659f9752e4ac3e44e3f1456e8e62c75"
            },
            "downloads": -1,
            "filename": "sql_helper-0.0.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9eef47d6cead5f7aa4e2a7a02029a2b4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13206,
            "upload_time": "2024-12-02T19:10:18",
            "upload_time_iso_8601": "2024-12-02T19:10:18.750258Z",
            "url": "https://files.pythonhosted.org/packages/47/87/6c5f838fa509774d4ef5f88af0080471ff44ff70d2e0af850a486b473f70/sql_helper-0.0.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-02 19:10:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kenjyco",
    "github_project": "sql-helper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "bg-helper",
            "specs": []
        },
        {
            "name": "click",
            "specs": [
                [
                    ">=",
                    "6.0"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": []
        },
        {
            "name": "psycopg2-binary",
            "specs": [
                [
                    ">=",
                    "2.8"
                ],
                [
                    "<",
                    "3"
                ]
            ]
        },
        {
            "name": "settings-helper",
            "specs": []
        },
        {
            "name": "pymysql",
            "specs": [
                [
                    ">=",
                    "1.1.1"
                ]
            ]
        },
        {
            "name": "pymysql",
            "specs": [
                [
                    ">=",
                    "0.9.3"
                ]
            ]
        },
        {
            "name": "pymysql",
            "specs": [
                [
                    "!=",
                    "1.0.0"
                ],
                [
                    ">=",
                    "0.9.3"
                ]
            ]
        },
        {
            "name": "sqlalchemy",
            "specs": [
                [
                    "!=",
                    "2.0.28"
                ],
                [
                    "!=",
                    "2.0.25"
                ],
                [
                    "!=",
                    "2.0.13"
                ],
                [
                    "!=",
                    "2.0.22"
                ],
                [
                    "!=",
                    "2.0.21"
                ],
                [
                    "!=",
                    "2.0.0"
                ],
                [
                    "!=",
                    "2.0.27"
                ],
                [
                    "!=",
                    "2.0.14"
                ],
                [
                    "!=",
                    "2.0.26"
                ],
                [
                    "!=",
                    "2.0.19"
                ],
                [
                    "!=",
                    "2.0.4"
                ],
                [
                    "!=",
                    "2.0.9"
                ],
                [
                    "!=",
                    "2.0.6"
                ],
                [
                    "!=",
                    "2.0.15"
                ],
                [
                    "!=",
                    "2.0.12"
                ],
                [
                    "!=",
                    "2.0.2"
                ],
                [
                    "!=",
                    "2.0.29"
                ],
                [
                    "!=",
                    "2.0.10"
                ],
                [
                    "!=",
                    "2.0.17"
                ],
                [
                    "!=",
                    "2.0.8"
                ],
                [
                    "!=",
                    "2.0.18"
                ],
                [
                    "!=",
                    "2.0.7"
                ],
                [
                    "!=",
                    "2.0.24"
                ],
                [
                    ">=",
                    "1.3"
                ],
                [
                    "!=",
                    "2.0.23"
                ],
                [
                    "!=",
                    "2.0.20"
                ],
                [
                    "!=",
                    "2.0.3"
                ],
                [
                    "!=",
                    "2.0.30"
                ],
                [
                    "!=",
                    "2.0.11"
                ],
                [
                    "!=",
                    "2.0.1"
                ],
                [
                    "!=",
                    "2.0.16"
                ],
                [
                    "!=",
                    "2.0.5.post1"
                ]
            ]
        },
        {
            "name": "sqlalchemy",
            "specs": [
                [
                    ">=",
                    "1.3"
                ]
            ]
        }
    ],
    "lcname": "sql-helper"
}
        
Ken
Elapsed time: 0.38963s