Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Ipython ODBC SQL Magic for Dawet

Project description

Ipython ODBC SQL Magic

Run SQL directly from Jupyter Notebook cell using ODBC without SQLAlchemy


Latest Development

$ pip3 install --user

Spesific Tag

$ pip3 install<tag>/ipython-dawet-sql-<tag>.zip

You can find available tag here


Load Extention

%load_ext dawetsql

Database Connection

Open Connection Using Line Magic

%dawetsql --dsn dsnname --user username --password secretPassword

With connection string

%dawetsql --connection "Driver={MariaDB ODBC 3.0 Driver};Server=localhost;UID=myUsername;PWD=myPassword;DB=myDatabase;Port=3306"

Available arguments

Arguments Type Default Descriptions
-c --chunksize Integer 100 Set ODBC Fetch Size
-x --connection String None ODBC Connection String
-a --reconnect Boolean False Try to reconnect if session expired
-r --retry Integer 3 Maximum reconnect retry

Close Connection




Run SQL Query

SELECT * FROM tables
WHERE somecolumn = 'somevalue'

Query Results Preview is presented using pandas dataframe with default limit 10 rows. You can access preview dataframe within notebook by calling _ variable.

Available arguments

Arguments Type Default Descriptions
-l --limit Integer 10 Limit Query result preview
-o --output String _ Result output. Currently only support exporting result to variable, csv, and pickle

Cell Magic Advance Usage

Store Query Result to Variable

%%dawetsql --ouput variablename
SELECT * FROM tables
WHERE somecolumn = 'somevalue'

Export Query Result to CSV

%%dawetsql --output filename.csv
SELECT * FROM tables
WHERE somecolumn = 'somevalue'

Export Query Result to Pickle

%%dawetsql --output picklename.pkl
SELECT * FROM tables
WHERE somecolumn = 'somevalue'


Schema Explorer Widget

Widget that help you explore database schema, table, columns name and type.

%explorer [-f --force]

Table Detail

table detail

Query Builder

query builder

Table Data Preview

query builder


You can find ipython-dawet-sql settings file in ~/.dawetsql/settings.ini. Currently, it is used only to store database schema query string.


This package is released under MIT License

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 ipython-dawet-sql, version 0.1b3
Filename, size File type Python version Upload date Hashes
Filename, size ipython-dawet-sql-0.1b3.tar.gz (7.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page