Skip to main content

Ipython ODBC SQL Magic for Dawet

Project description

Ipython ODBC SQL Magic

Run SQL directly from Jupyter Notebook cell using ODBC without SQLAlchemy

Installation

Latest Development

$ pip3 install https://gitlab.com/wakataw/ipython-dawet-sql/-/archive/master/ipython-dawet-sql-master.zip --user

Spesific Tag

$ pip3 install https://gitlab.com/wakataw/ipython-dawet-sql/-/archive/<tag>/ipython-dawet-sql-<tag>.zip

You can find available tag here

Usage

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

%dawetsqlclose

Reconnect

%dawetsqlreconnect

Run SQL Query

%%dawetsql
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'

Widgets

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

Settings

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

Legal

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.

Source Distribution

ipython-dawet-sql-0.1b5.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file ipython-dawet-sql-0.1b5.tar.gz.

File metadata

  • Download URL: ipython-dawet-sql-0.1b5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2

File hashes

Hashes for ipython-dawet-sql-0.1b5.tar.gz
Algorithm Hash digest
SHA256 fd76a8a8508094edb6fdfbd515a391aaa62092a8857fe2d9e57fcd98f4d83981
MD5 e72131230b054a07eb60f4fef522d1ac
BLAKE2b-256 48723a47cdd86795fb80de8b0a71dbbd35fad0eae08fa949c7ab3b5fcd809c36

See more details on using hashes here.

Supported by

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