This release is a pre-release and may not be stable for production use.
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
Query Builder
Table Data Preview
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
Release files for ipython-dawet-sql 0.1b6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipython-dawet-sql-0.1b6.tar.gz | 7.6 kB | Details |
Release files / ipython-dawet-sql-0.1b6.tar.gz
| Download URL | ipython-dawet-sql-0.1b6.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e65a4a36db1de0acdba30848b05ef5daa46eed0bb508d1a80d5206a4b8078963
|
|
BLAKE2b-256 checksum How to use checksums |
bf5fbcf7473a3df7e0cff6f16617d6771ecaa37bf204e7eedcd1e2096da383ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|