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.1b6.tar.gz (7.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for ipython-dawet-sql-0.1b6.tar.gz
Algorithm Hash digest
SHA256 e65a4a36db1de0acdba30848b05ef5daa46eed0bb508d1a80d5206a4b8078963
MD5 bfc766563ec83fafa433749dd6cce97a
BLAKE2b-256 bf5fbcf7473a3df7e0cff6f16617d6771ecaa37bf204e7eedcd1e2096da383ad

See more details on using hashes here.

Supported by

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