Skip to content

Commit e205005

Browse files
committed
Added SQL-related notebooks
1 parent 55c6809 commit e205005

38 files changed

+18415
-737
lines changed

PyData/UsefulPackages.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sweetviz: https://github.com/fbdesignpro/sweetviz
2929
dataprep: https://github.com/sfu-db/dataprep
3030
sidetable: https://github.com/chris1610/sidetable
3131
dataprofiler: https://github.com/capitalone/DataProfiler
32+
skimpy: https://github.com/aeturrell/skimpy
3233

3334
# Database profiling
3435
https://github.com/darenasc/auto-eda
@@ -249,7 +250,6 @@ autoscraper: https://github.com/alirezamika/autoscraper
249250
boto3: Interface to S3
250251
PyHive: https://github.com/dropbox/PyHive
251252
Amazon S3 with SQL syntax: PyAthena - use plain 'ol SQL: https://github.com/laughingman7743/PyAthena
252-
Pandas syntax with Apache Spark: koalas - https://github.com/databricks/koalas
253253
PySpark: https://jacobcelestine.com/knowledge_repo/colab_and_pyspark/
254254
Dask/Coiled
255255
Dask-SQL: https://github.com/nils-braun/dask-sql

PyData/bookmarks.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ https://hakibenita.com/postgresql-unknown-features
1212
https://jacobcelestine.com/knowledge_repo/colab_and_pyspark/
1313
https://sparkbyexamples.com/
1414
chaining: https://mungingdata.com/pyspark/chaining-dataframe-transformations/
15-
https://phoenixnap.com/kb/install-spark-on-ubuntu
16-
https://www.how2shout.com/linux/installing-apache-spark-on-ubuntu-20-04-or-18-04/
15+
installing: https://phoenixnap.com/kb/install-spark-on-ubuntu
16+
installing: https://www.how2shout.com/linux/installing-apache-spark-on-ubuntu-20-04-or-18-04/
1717
installing: https://computingforgeeks.com/how-to-install-apache-spark-on-ubuntu-debian/
1818
installing, win10: https://phoenixnap.com/kb/install-spark-on-windows-10
1919
installing, win10: https://kontext.tech/column/spark/450/install-spark-300-on-windows-10
@@ -29,3 +29,6 @@ https://tutonics.com/2012/12/linux-file-permissions-chmod-umask.html
2929
# Understanding Imports/Packaging
3030
https://tenthousandmeters.com/blog/python-behind-the-scenes-11-how-the-python-import-system-works/
3131
https://towardsdatascience.com/on-writing-clean-jupyter-notebooks-abdf6c708c75
32+
33+
# Cheat Sheets
34+
Python: https://github.com/gto76/python-cheatsheet
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "306bfc7c-da99-4221-aba4-1932c2810ed2",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import pandas as pd\n",
11+
"import pyodbc\n",
12+
"from getpass import getpass"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": 2,
18+
"id": "c1b19fba-c9ea-4eec-8e8e-0c0cdac05608",
19+
"metadata": {},
20+
"outputs": [
21+
{
22+
"name": "stdout",
23+
"output_type": "stream",
24+
"text": [
25+
"Python 3.8.10 (default, May 19 2021, 13:12:57) [MSC v.1916 64 bit (AMD64)]\n"
26+
]
27+
}
28+
],
29+
"source": [
30+
"!python -V -V"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 3,
36+
"id": "12816fcf-4778-45d9-8265-3d0966f24a5b",
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"dsn = 'SRMDB_P'"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 4,
46+
"id": "8051234e-1432-4bed-9001-8c27b2b826f0",
47+
"metadata": {},
48+
"outputs": [
49+
{
50+
"name": "stdin",
51+
"output_type": "stream",
52+
"text": [
53+
"Enter your mainframe password: ········\n"
54+
]
55+
}
56+
],
57+
"source": [
58+
"user = 'nmdpur'\n",
59+
"pwd = getpass(\"Enter your mainframe password:\")"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 5,
65+
"id": "b5ca1cec-8a48-47e7-bcc1-dd3fe378f3e3",
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"sql = \"\"\"\n",
70+
"SELECT\n",
71+
" CURRENT TIMESTAMP as DATETIME_NOW\n",
72+
"FROM\n",
73+
" SYSIBM.SYSDUMMY1\n",
74+
"\"\"\""
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 6,
80+
"id": "ca61b9c4-0ab4-4ebd-a975-a0ee94a6b1a1",
81+
"metadata": {},
82+
"outputs": [],
83+
"source": [
84+
"# Execute query and save results as a pandas dataframe\n",
85+
"with pyodbc.connect(f'DSN={dsn};UID={user};PWD={pwd}') as conn:\n",
86+
" df = pd.read_sql(sql, conn)"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 7,
92+
"id": "e70e4228-6405-4c63-9c13-75a6013a8988",
93+
"metadata": {},
94+
"outputs": [
95+
{
96+
"data": {
97+
"text/html": [
98+
"<div>\n",
99+
"<style scoped>\n",
100+
" .dataframe tbody tr th:only-of-type {\n",
101+
" vertical-align: middle;\n",
102+
" }\n",
103+
"\n",
104+
" .dataframe tbody tr th {\n",
105+
" vertical-align: top;\n",
106+
" }\n",
107+
"\n",
108+
" .dataframe thead th {\n",
109+
" text-align: right;\n",
110+
" }\n",
111+
"</style>\n",
112+
"<table border=\"1\" class=\"dataframe\">\n",
113+
" <thead>\n",
114+
" <tr style=\"text-align: right;\">\n",
115+
" <th></th>\n",
116+
" <th>DATETIME_NOW</th>\n",
117+
" </tr>\n",
118+
" </thead>\n",
119+
" <tbody>\n",
120+
" <tr>\n",
121+
" <th>0</th>\n",
122+
" <td>2021-05-21 17:52:06.436452</td>\n",
123+
" </tr>\n",
124+
" </tbody>\n",
125+
"</table>\n",
126+
"</div>"
127+
],
128+
"text/plain": [
129+
" DATETIME_NOW\n",
130+
"0 2021-05-21 17:52:06.436452"
131+
]
132+
},
133+
"execution_count": 7,
134+
"metadata": {},
135+
"output_type": "execute_result"
136+
}
137+
],
138+
"source": [
139+
"df.head()"
140+
]
141+
}
142+
],
143+
"metadata": {
144+
"kernelspec": {
145+
"display_name": "Py3.9 (data_eval)",
146+
"language": "python",
147+
"name": "data_eval"
148+
},
149+
"language_info": {
150+
"codemirror_mode": {
151+
"name": "ipython",
152+
"version": 3
153+
},
154+
"file_extension": ".py",
155+
"mimetype": "text/x-python",
156+
"name": "python",
157+
"nbconvert_exporter": "python",
158+
"pygments_lexer": "ipython3",
159+
"version": "3.9.8"
160+
}
161+
},
162+
"nbformat": 4,
163+
"nbformat_minor": 5
164+
}

0 commit comments

Comments
 (0)