forked from catherinedevlin/ipython-sql
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial version added * sql pagination added * test fixed * sort columns added * changelog updated * Allows to add multiple tables to a single notebook * tests added * testing on binder * binder test * _get_binder_hub_url added * webscoket connection added * table_widget added * rebase * lint * widgets directory name changed * imports * short import removed * __init__ added * import fixed * lint * import * telemetry added * pagination bug on Jupyter nb fixed * docs added * clean * lint * tests added * path fixed * path changed * lint * table_widget js and css files added * empty commit invoke CI * apt.txt added with nodejs * apt removed. doc updated * apt removed * docs fixed * apt.txt added * docs * cleaned * code review fixes * code review fixes * lint * lint * psutil added * lint * link to binder fixed * table_widget.jpg removed
- Loading branch information
Showing
18 changed files
with
1,317 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
include README.rst | ||
include NEWS.rst | ||
include LICENSE | ||
include src/sql/widgets/table_widget/css/* | ||
include src/sql/widgets/table_widget/js/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,9 +66,11 @@ | |
"repository_branch": repository_branch, | ||
"analytics": {"google_analytics_id": "G-JBZ8NNQSLN"}, | ||
"home_page_in_toc": True, | ||
"announcement": ("To launch a tutorial, click on the 🚀 button " | ||
"below! Join us on " | ||
"<a href='https://ploomber.io/community/'>Slack!</a>"), | ||
"announcement": ( | ||
"To launch a tutorial, click on the 🚀 button " | ||
"below! Join us on " | ||
"<a href='https://ploomber.io/community/'>Slack!</a>" | ||
), | ||
"use_repository_button": True, | ||
"use_edit_page_button": False, | ||
"use_issues_button": True, | ||
|
@@ -106,18 +108,17 @@ | |
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. | ||
html_static_path = ['_static'] | ||
html_static_path = ["_static"] | ||
|
||
# Load custom stylesheets to support Algolia search. | ||
html_css_files = [ | ||
'algolia.css', | ||
'https://cdn.jsdelivr.net/npm/@docsearch/css@3' | ||
] | ||
html_css_files = ["algolia.css", "https://cdn.jsdelivr.net/npm/@docsearch/css@3"] | ||
|
||
# Load custom javascript to support Algolia search. Note that the sequence | ||
# defined below (external first) is intentional! | ||
html_js_files = [ | ||
('https://cdn.jsdelivr.net/npm/@docsearch/[email protected]/dist/umd/index.js', | ||
{'defer': 'defer'}), | ||
('algolia.js', {'defer': 'defer'}) | ||
( | ||
"https://cdn.jsdelivr.net/npm/@docsearch/[email protected]/dist/umd/index.js", | ||
{"defer": "defer"}, | ||
), | ||
("algolia.js", {"defer": "defer"}), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
jupytext: | ||
notebook_metadata_filter: myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.5 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
myst: | ||
html_meta: | ||
description lang=en: Templatize SQL queries in Jupyter via JupySQL | ||
keywords: jupyter, sql, jupysql, jinja | ||
property=og:locale: en_US | ||
--- | ||
|
||
# Table Explorer | ||
|
||
|
||
```{versionadded} 0.7.6 | ||
~~~ | ||
pip install jupysql --upgrade | ||
~~~ | ||
``` | ||
|
||
In this guide, we demonstrate how to use JupySQL's table explorer to visualize SQL tables in HTML format and interact with them efficiently. By running SQL queries in the background instead of loading the data into memory, we minimize the resource consumption and processing time required for handling large datasets, making the interaction with the SQL tables faster and more streamlined. | ||
|
||
```{note} | ||
If you are using JupyterLab or Binder, please ensure that you have installed the latest version of the JupySQL plugin by running the following command: `pip install jupysql-plugin --upgrade`. | ||
``` | ||
|
||
Let's start by preparing our dataset. We'll be using the [NYC taxi dataset](https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page). | ||
|
||
## Download the data | ||
|
||
```{code-cell} ipython3 | ||
from pathlib import Path | ||
from urllib.request import urlretrieve | ||
url = "https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet" | ||
if not Path("yellow_tripdata_2021-01.parquet").is_file(): | ||
urlretrieve(url, "yellow_tripdata_2021.parquet") | ||
``` | ||
|
||
## Set connection | ||
|
||
After our dataset is ready, we should set our connection. | ||
|
||
For this demonstration, we'll be using the `DuckDB` connection. | ||
|
||
```{code-cell} ipython3 | ||
%load_ext sql | ||
%sql duckdb:// | ||
``` | ||
|
||
## Create the table | ||
|
||
To create the table, use the `explore` attribute and specify the name of the table that was just downloaded. | ||
|
||
```{code-cell} ipython3 | ||
:tags: [] | ||
%sqlcmd explore --table "yellow_tripdata_2021.parquet" | ||
``` | ||
|
||
|
||
See interactive and live example on [Binder](https://binder.ploomber.io/v2/gh/ploomber/jupysql/master?urlpath=lab/tree/doc/user-guide/table_explorer.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from sql.widgets.table_widget.table_widget import TableWidget | ||
|
||
__all__ = ["TableWidget"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.sort-button { | ||
background: none; | ||
border: none; | ||
} | ||
|
||
.sort-button.selected { | ||
background: #efefef; | ||
border: 1px solid #767676; | ||
} | ||
|
||
.pages-buttons button.selected { | ||
background: #efefef; | ||
border: 1px solid #767676; | ||
border-radius: 2px; | ||
} | ||
.pages-buttons button { | ||
background: none; | ||
border: none; | ||
padding: 0 10px; | ||
} | ||
.jupysql-table-widget { | ||
display: inline; | ||
} |
Oops, something went wrong.