Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Ipython ODBC SQL Magic

IPython Magic untuk menjalankan SQL menggunakan ODBC secara langsung pada notebook cell.

Pemasangan

$ pip3 install ipython-dawet-sql

Penggunaan

Load Ekstensi

Untuk dapat menggunakan, ekstensi harus di load terlebih dahulu ke notebook yang sedang digunakan.

In [ ]: %load_ext dawetsql

Database Connection

Membuka Koneksi

In [ ]: %dawetsql

Setelah line magic dieksekusi, selanjutnya isi form sesuai dengan konfigurasi ODBC. Username dan password optional jika sudah diset di konfigurasi ODBC sistem.

query builder

Untuk me-restart koneksi, cukup klik connect, dawetsql akan otomatis menutup koneksi terlebih dahulu sebelum membuka koneksi baru lagi.

Menutup Koneksi

In [ ]: %dawetsqlclose

Menjalankan SQL

In [ ]: %%dawetsql
        SELECT * FROM tables
        WHERE somecolumn = 'somevalue'

Preview hasil query ditampilkan menggunakan pandas.DataFrame dengan default limit 10 baris.

Available arguments

Arguments Type Default Descriptions
-l --limit Integer 10 Set limit query untuk preview
-o --output String _ Nama output hasil query.

Contoh Penggunaan

Menyimpan Hasil query ke Python Variable

In [ ]: %%dawetsql --ouput variablename
        SELECT * FROM tables
        WHERE somecolumn = 'somevalue'

Menyimpan Hasil Query ke File

Cell Magic %%dawetsql akan otomatis menyimpan hasil query kedalam file jika nama output memiliki ekstensi .csv, .pkl, dan .xlsx

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

Akses Python Variable dari SQL Query

Untuk mengakses variable dari local namespace, gunakan format ?namavariable sebagai placeholder pada SQL Query. Tanda petik (') akan otomatis ditambahkan jika tipe variable bukan int atau float.

In [1]: low = 1
        high = 100
        other_column_name = "something"

pada magic cell

In [2]: %%dawetsql
        SELECT 
            *
        FROM
            TABLE
        WHERE
            SOME_COLUMN BETWEEN ?low AND ?high
            AND OTHER_COLUMN = ?other_column_name

SQL Query akan dikonversi menjadi

SELECT 
    *
FROM
    TABLE
WHERE
    SOME_COLUMN BETWEEN 1 AND 100
    AND OTHER_COLUMN = 'something'

Widgets

Schema Explorer Widget

Widget ini digunakan untuk meng-explore skema, tabel, kolom, dan tipe kolom pada database.

%explorer [-f --force]

Table Detail

table detail

Query Builder

query builder

Table Data Preview

query builder

Settings

File konfigurasi dawetsql tersimpan pada direktori ~/.dawetsql.

Lain-lain

SQL Autocomplete

Cell magic %%dawetsql mendukung SQL Autocomplete. Fitur ini masih bersifat eksperimental. Autocomplete untuk nama tabel dan kolom tersedia setelah pengguna menjalankan magic %explore. Untuk pengguna lama, jalankan %explorer -f, lalu restart notebook.

Package ini dirilis di bawah lisensi MIT.

Metadata

Release files for ipython-dawet-sql 0.1b10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipython-dawet-sql 0.1b10
File Size Uploaded Provenance
ipython-dawet-sql-0.1b10.tar.gz 11.3 kB Without provenance Details

Release files / ipython-dawet-sql-0.1b10.tar.gz

Download URL ipython-dawet-sql-0.1b10.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0bb98261d2daba6077459a19af97b444628da54722edb5259508d1c5be5fa773
BLAKE2b-256 checksum
How to use checksums
156394f98b2dd59be9a31ff0f4e3dacfc5148f45457b59eacc244303f0c76b60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

Security for ipython-dawet-sql 0.1b10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page