Skip to main content

Helper funcs and tools for working with SQL in mysql, postgresql, and more

Project description

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://.

Install

Ensure the pg_config executable is on the system

$ sudo apt-get install -y libpq-dev

or

$ brew install postgresql

Then install sql-helper

$ 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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sql_helper-0.0.18-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file sql_helper-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: sql_helper-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for sql_helper-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 9579b82ba0d97854c25451911b28cb121a7f2a6c0e17cbb07601e089940c0384
MD5 ecd40a36cb4ef933714fcc9f1c57a74e
BLAKE2b-256 80fc512ce11bf510ac77bdfc5642d151dcbb89b820dabc5934f6884b576b6f40

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page