Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Dead simple wrapper for pandas and sqlalchemy

Project description

SQLSorcery: Dead simple wrapper for pandas and sqlalchemy

SQLSorcery is just some good old fashion syntactic sugar 🍬. It really doesn’t do anything new. It just makes doing it a little bit easier. It started as a connection wrapper for SQLAlchemy to cut down on the need for boilerplate code that was used to keep the database credentials secret, connect to the database, and then pass the connection to Pandas for queries and inserts.

It wasn’t much code, but needing to cut and paste it for each new project seemed like a recipe for bugs. So here we are. We’ve added more utility methods to the module as well as added all of the basic dialects of SQL that SQLAlchemy supports.

In many cases, the methods available are less robust than the underlying libraries and are more of a shortcut. When you need something that is outside the bounds of the defaults you can always drop back down into Pandas or SQLAlchemy to get more functionality/flexibility.

Getting Started

Install this library

$ pipenv install sqlsorcery

By default, sqlsorcery does not install the sql dialect specific python drivers. To install these, you can specify the dialects as a comma separated list of each dialect you will need drivers for.

$ pipenv install sqlsorcery[mssql]


$ pipenv install sqlsorcery[mysql,postgres]

Setup .env file with credentials

For use with a single database:


Otherwise, refer to the documentation for instructions.


Query a table

from sqlsorcery import MSSQL

sql = MSSQL()
df = sql.query("SELECT * FROM my_table")

Query from a .sql file

from sqlsorcery import MSSQL

sql = MSSQL()
df = sql.query_from_file("filename.sql")

Insert into a table

from sqlsorcery import MSSQL
import pandas as pd

sample_data = [
    { "name": "Test 1", "value": 98 },
    { "name": "Test 2", "value": 100 },

df = pd.DataFrame(sample_data)
sql = MSSQL()
sql.insert_into("table_name", df)

Execute a stored procedure

from sqlsorcery import MSSQL

sql = MSSQL()


Documentation and tutorials available at

Project details

Download files

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

Files for sqlsorcery, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size sqlsorcery-0.1.5-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size sqlsorcery-0.1.5.tar.gz (6.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page