├── Access Databases Using Jupyter Notebook.pdf.ipynb
├── PyMySQL.PNG
├── SQL Tutorials.ipynb
├── SQLAlchemy.PNG
├── cx_oracle.PNG
├── ipython-sql.PNG
├── ipython-sql1.PNG
├── jupyter-sql.PNG
├── mysql1.PNG
├── mysql2.PNG
├── odbc0.PNG
├── odbc1.PNG
├── odbc2.PNG
├── odbc3.PNG
├── odbc4.PNG
├── odbc5.PNG
├── odbc6.PNG
├── ora_con.PNG
├── oracle1.PNG
├── oracle2.PNG
├── oracle3.PNG
├── oracle4.PNG
├── oracle5.PNG
├── pgAdmin.PNG
├── pgAdmin1.PNG
├── psycopg2.PNG
├── pyodbc.PNG
└── sqldb1.PNG
/Access Databases Using Jupyter Notebook.pdf.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 4,
6 | "metadata": {},
7 | "outputs": [
8 | {
9 | "name": "stdout",
10 | "output_type": "stream",
11 | "text": [
12 | "zsh:1: no matches found: nbconvert[webpdf]\n",
13 | "Note: you may need to restart the kernel to use updated packages.\n"
14 | ]
15 | }
16 | ],
17 | "source": [
18 | "pip install Pyppeteer"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {},
24 | "source": [
25 | "\n",
26 | "\n",
27 | "
\n",
28 | "\n",
29 | "
Prepared by Asif Bhat
\n",
30 | " \n",
31 | "Access Databases using Jupyter Notebook
\n",
32 | "\n",
33 | "\n",
34 | ""
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "# Prerequisites"
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "- Install Oracle Database 19c.\n",
49 | "\n",
50 | "\n",
51 | "\n",
52 | "- Install MS SQL Server 2019 Express edition.\n",
53 | "\n",
54 | "\n",
55 | "\n",
56 | "- Install PostgreSQL\n",
57 | "\n",
58 | "\n",
59 | "\n",
60 | "- Install MySQL"
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {},
66 | "source": [
67 | "### Install SQLAlchemy"
68 | ]
69 | },
70 | {
71 | "cell_type": "markdown",
72 | "metadata": {},
73 | "source": [
74 | "
"
75 | ]
76 | },
77 | {
78 | "cell_type": "markdown",
79 | "metadata": {},
80 | "source": [
81 | "### Install ipython-sql"
82 | ]
83 | },
84 | {
85 | "cell_type": "markdown",
86 | "metadata": {},
87 | "source": [
88 | "
"
89 | ]
90 | },
91 | {
92 | "cell_type": "markdown",
93 | "metadata": {},
94 | "source": [
95 | "### Install Pyodbc"
96 | ]
97 | },
98 | {
99 | "cell_type": "markdown",
100 | "metadata": {},
101 | "source": [
102 | "
"
103 | ]
104 | },
105 | {
106 | "cell_type": "markdown",
107 | "metadata": {},
108 | "source": [
109 | "### Install PyMySQL"
110 | ]
111 | },
112 | {
113 | "cell_type": "markdown",
114 | "metadata": {},
115 | "source": [
116 | "
"
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "metadata": {},
122 | "source": [
123 | "### Install cx_oracle"
124 | ]
125 | },
126 | {
127 | "cell_type": "markdown",
128 | "metadata": {},
129 | "source": [
130 | "
"
131 | ]
132 | },
133 | {
134 | "cell_type": "markdown",
135 | "metadata": {},
136 | "source": [
137 | "### Install psycopg2"
138 | ]
139 | },
140 | {
141 | "cell_type": "markdown",
142 | "metadata": {},
143 | "source": [
144 | "
"
145 | ]
146 | },
147 | {
148 | "cell_type": "code",
149 | "execution_count": 1,
150 | "metadata": {},
151 | "outputs": [],
152 | "source": [
153 | "import sqlalchemy\n",
154 | "import numpy\n",
155 | "import pandas as pd\n",
156 | "import warnings\n",
157 | "warnings.filterwarnings('ignore')"
158 | ]
159 | },
160 | {
161 | "cell_type": "markdown",
162 | "metadata": {},
163 | "source": [
164 | "### Connec to SQL Server Database using sqlalchemy"
165 | ]
166 | },
167 | {
168 | "cell_type": "markdown",
169 | "metadata": {},
170 | "source": [
171 | "Sample Database Used \n",
172 | " - https://www.sqlservertutorial.net/sql-server-sample-database/\n",
173 | " \n",
174 | " - https://www.sqlskills.com/resources/conferences/salesdb2014.zip"
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": 2,
180 | "metadata": {},
181 | "outputs": [],
182 | "source": [
183 | "engine_mssql = sqlalchemy.create_engine('mssql+pyodbc://localhost/salesdb?driver=SQL Server?Trusted_Connection=yes')"
184 | ]
185 | },
186 | {
187 | "cell_type": "code",
188 | "execution_count": 3,
189 | "metadata": {},
190 | "outputs": [
191 | {
192 | "name": "stdout",
193 | "output_type": "stream",
194 | "text": [
195 | "connecting with engine Engine(mssql+pyodbc://localhost/salesdb?driver=SQL+Server)\n"
196 | ]
197 | }
198 | ],
199 | "source": [
200 | "print(\"connecting with engine \" + str(engine_mssql))"
201 | ]
202 | },
203 | {
204 | "cell_type": "code",
205 | "execution_count": 4,
206 | "metadata": {},
207 | "outputs": [
208 | {
209 | "name": "stdout",
210 | "output_type": "stream",
211 | "text": [
212 | "['Customers', 'Employees', 'Products', 'Sales']\n"
213 | ]
214 | }
215 | ],
216 | "source": [
217 | "print(engine_mssql.table_names())"
218 | ]
219 | },
220 | {
221 | "cell_type": "code",
222 | "execution_count": 5,
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "con_mssql = engine_mssql.connect()"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": 6,
232 | "metadata": {},
233 | "outputs": [
234 | {
235 | "data": {
236 | "text/html": [
237 | "\n",
238 | "\n",
251 | "
\n",
252 | " \n",
253 | " \n",
254 | " | \n",
255 | " EmployeeID | \n",
256 | " FirstName | \n",
257 | " MiddleInitial | \n",
258 | " LastName | \n",
259 | "
\n",
260 | " \n",
261 | " \n",
262 | " \n",
263 | " 0 | \n",
264 | " 1 | \n",
265 | " Abraham | \n",
266 | " e | \n",
267 | " Bennet | \n",
268 | "
\n",
269 | " \n",
270 | " 1 | \n",
271 | " 2 | \n",
272 | " Reginald | \n",
273 | " l | \n",
274 | " Blotchet-Halls | \n",
275 | "
\n",
276 | " \n",
277 | " 2 | \n",
278 | " 3 | \n",
279 | " Cheryl | \n",
280 | " a | \n",
281 | " Carson | \n",
282 | "
\n",
283 | " \n",
284 | " 3 | \n",
285 | " 4 | \n",
286 | " Michel | \n",
287 | " e | \n",
288 | " DeFrance | \n",
289 | "
\n",
290 | " \n",
291 | " 4 | \n",
292 | " 5 | \n",
293 | " Innes | \n",
294 | " e | \n",
295 | " del Castillo | \n",
296 | "
\n",
297 | " \n",
298 | " 5 | \n",
299 | " 6 | \n",
300 | " Ann | \n",
301 | " u | \n",
302 | " Dull | \n",
303 | "
\n",
304 | " \n",
305 | " 6 | \n",
306 | " 7 | \n",
307 | " Marjorie | \n",
308 | " r | \n",
309 | " Green | \n",
310 | "
\n",
311 | " \n",
312 | " 7 | \n",
313 | " 8 | \n",
314 | " Morningstar | \n",
315 | " r | \n",
316 | " Greene | \n",
317 | "
\n",
318 | " \n",
319 | " 8 | \n",
320 | " 9 | \n",
321 | " Burt | \n",
322 | " r | \n",
323 | " Gringlesby | \n",
324 | "
\n",
325 | " \n",
326 | " 9 | \n",
327 | " 10 | \n",
328 | " Sheryl | \n",
329 | " u | \n",
330 | " Hunter | \n",
331 | "
\n",
332 | " \n",
333 | " 10 | \n",
334 | " 11 | \n",
335 | " Livia | \n",
336 | " a | \n",
337 | " Karsen | \n",
338 | "
\n",
339 | " \n",
340 | " 11 | \n",
341 | " 12 | \n",
342 | " Charlene | \n",
343 | " o | \n",
344 | " Locksley | \n",
345 | "
\n",
346 | " \n",
347 | " 12 | \n",
348 | " 13 | \n",
349 | " Stearns | \n",
350 | " a | \n",
351 | " MacFeather | \n",
352 | "
\n",
353 | " \n",
354 | " 13 | \n",
355 | " 14 | \n",
356 | " Heather | \n",
357 | " c | \n",
358 | " McBadden | \n",
359 | "
\n",
360 | " \n",
361 | " 14 | \n",
362 | " 15 | \n",
363 | " Michael | \n",
364 | " ' | \n",
365 | " O'Leary | \n",
366 | "
\n",
367 | " \n",
368 | " 15 | \n",
369 | " 16 | \n",
370 | " Sylvia | \n",
371 | " a | \n",
372 | " Panteley | \n",
373 | "
\n",
374 | " \n",
375 | " 16 | \n",
376 | " 17 | \n",
377 | " Albert | \n",
378 | " i | \n",
379 | " Ringer | \n",
380 | "
\n",
381 | " \n",
382 | " 17 | \n",
383 | " 18 | \n",
384 | " Anne | \n",
385 | " i | \n",
386 | " Ringer | \n",
387 | "
\n",
388 | " \n",
389 | " 18 | \n",
390 | " 19 | \n",
391 | " Meander | \n",
392 | " m | \n",
393 | " Smith | \n",
394 | "
\n",
395 | " \n",
396 | " 19 | \n",
397 | " 20 | \n",
398 | " Dean | \n",
399 | " t | \n",
400 | " Straight | \n",
401 | "
\n",
402 | " \n",
403 | " 20 | \n",
404 | " 21 | \n",
405 | " Dirk | \n",
406 | " t | \n",
407 | " Stringer | \n",
408 | "
\n",
409 | " \n",
410 | " 21 | \n",
411 | " 22 | \n",
412 | " Johnson | \n",
413 | " h | \n",
414 | " White | \n",
415 | "
\n",
416 | " \n",
417 | " 22 | \n",
418 | " 23 | \n",
419 | " Akiko | \n",
420 | " o | \n",
421 | " Yokomoto | \n",
422 | "
\n",
423 | " \n",
424 | "
\n",
425 | "
"
426 | ],
427 | "text/plain": [
428 | " EmployeeID FirstName MiddleInitial LastName\n",
429 | "0 1 Abraham e Bennet\n",
430 | "1 2 Reginald l Blotchet-Halls\n",
431 | "2 3 Cheryl a Carson\n",
432 | "3 4 Michel e DeFrance\n",
433 | "4 5 Innes e del Castillo\n",
434 | "5 6 Ann u Dull\n",
435 | "6 7 Marjorie r Green\n",
436 | "7 8 Morningstar r Greene\n",
437 | "8 9 Burt r Gringlesby\n",
438 | "9 10 Sheryl u Hunter\n",
439 | "10 11 Livia a Karsen\n",
440 | "11 12 Charlene o Locksley\n",
441 | "12 13 Stearns a MacFeather\n",
442 | "13 14 Heather c McBadden\n",
443 | "14 15 Michael ' O'Leary\n",
444 | "15 16 Sylvia a Panteley\n",
445 | "16 17 Albert i Ringer\n",
446 | "17 18 Anne i Ringer\n",
447 | "18 19 Meander m Smith\n",
448 | "19 20 Dean t Straight\n",
449 | "20 21 Dirk t Stringer\n",
450 | "21 22 Johnson h White\n",
451 | "22 23 Akiko o Yokomoto"
452 | ]
453 | },
454 | "execution_count": 6,
455 | "metadata": {},
456 | "output_type": "execute_result"
457 | }
458 | ],
459 | "source": [
460 | "query = \"select * from Employees\"\n",
461 | "df_mssql = pd.read_sql_query(query, con_mssql)\n",
462 | "df_mssql"
463 | ]
464 | },
465 | {
466 | "cell_type": "markdown",
467 | "metadata": {},
468 | "source": [
469 | "### Connec to SQL Server Database using ipython-sql"
470 | ]
471 | },
472 | {
473 | "cell_type": "markdown",
474 | "metadata": {},
475 | "source": [
476 | "__To Connect to SQL Server Database using ipython-sql we neeed to first create a odbc connection__"
477 | ]
478 | },
479 | {
480 | "cell_type": "markdown",
481 | "metadata": {},
482 | "source": [
483 | "__Steps to create odbc connection__\n",
484 | "\n",
485 | "1) Go to ODBC Data Source Administration.\n",
486 | "\n",
487 | "2) Click on Add and select the __SQL Serer__ and hit Finish."
488 | ]
489 | },
490 | {
491 | "cell_type": "markdown",
492 | "metadata": {},
493 | "source": [
494 | "
"
495 | ]
496 | },
497 | {
498 | "cell_type": "markdown",
499 | "metadata": {},
500 | "source": [
501 | "3) Name your ODBC connection (sqldb).\n",
502 | "\n",
503 | "4) Specify SQL Server name and hit finish."
504 | ]
505 | },
506 | {
507 | "cell_type": "markdown",
508 | "metadata": {},
509 | "source": [
510 | "
"
511 | ]
512 | },
513 | {
514 | "cell_type": "markdown",
515 | "metadata": {},
516 | "source": [
517 | "5) Use SQL Server authentication to connect to the database (Salesdb in this case)."
518 | ]
519 | },
520 | {
521 | "cell_type": "markdown",
522 | "metadata": {},
523 | "source": [
524 | "
"
525 | ]
526 | },
527 | {
528 | "cell_type": "markdown",
529 | "metadata": {},
530 | "source": [
531 | "6) Select the database (salesdb) and click next."
532 | ]
533 | },
534 | {
535 | "cell_type": "markdown",
536 | "metadata": {},
537 | "source": [
538 | "
"
539 | ]
540 | },
541 | {
542 | "cell_type": "markdown",
543 | "metadata": {},
544 | "source": [
545 | "7) Test Data Source and hit finish."
546 | ]
547 | },
548 | {
549 | "cell_type": "markdown",
550 | "metadata": {},
551 | "source": [
552 | "
"
553 | ]
554 | },
555 | {
556 | "cell_type": "markdown",
557 | "metadata": {},
558 | "source": [
559 | "8) sqldb data source will be visible in the list now."
560 | ]
561 | },
562 | {
563 | "cell_type": "markdown",
564 | "metadata": {},
565 | "source": [
566 | "
"
567 | ]
568 | },
569 | {
570 | "cell_type": "code",
571 | "execution_count": 7,
572 | "metadata": {},
573 | "outputs": [
574 | {
575 | "name": "stdout",
576 | "output_type": "stream",
577 | "text": [
578 | "(pyodbc.ProgrammingError) ('42000', \"[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'dstran'. Reason: The password of the account has expired. (18487) (SQLDriverConnect); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'dstran'. Reason: The password of the account has expired. (18487)\")\n",
579 | "(Background on this error at: http://sqlalche.me/e/13/f405)\n",
580 | "Connection info needed in SQLAlchemy format, example:\n",
581 | " postgresql://username:password@hostname/dbname\n",
582 | " or an existing connection: dict_keys([])\n"
583 | ]
584 | }
585 | ],
586 | "source": [
587 | "%load_ext sql\n",
588 | "%sql mssql+pyodbc://dstran:dstran@sqldb"
589 | ]
590 | },
591 | {
592 | "cell_type": "code",
593 | "execution_count": 8,
594 | "metadata": {
595 | "scrolled": true
596 | },
597 | "outputs": [
598 | {
599 | "name": "stdout",
600 | "output_type": "stream",
601 | "text": [
602 | "Environment variable $DATABASE_URL not set, and no connect string given.\n",
603 | "Connection info needed in SQLAlchemy format, example:\n",
604 | " postgresql://username:password@hostname/dbname\n",
605 | " or an existing connection: dict_keys([])\n"
606 | ]
607 | }
608 | ],
609 | "source": [
610 | "%%sql\n",
611 | "\n",
612 | "select top 10 * from Employees"
613 | ]
614 | },
615 | {
616 | "cell_type": "code",
617 | "execution_count": 9,
618 | "metadata": {},
619 | "outputs": [],
620 | "source": [
621 | "%reload_ext sql"
622 | ]
623 | },
624 | {
625 | "cell_type": "code",
626 | "execution_count": 10,
627 | "metadata": {},
628 | "outputs": [
629 | {
630 | "name": "stdout",
631 | "output_type": "stream",
632 | "text": [
633 | "The sql extension is already loaded. To reload it, use:\n",
634 | " %reload_ext sql\n"
635 | ]
636 | }
637 | ],
638 | "source": [
639 | "%load_ext sql\n",
640 | "%sql mssql+pyodbc://abhat:abhat@sqldb1"
641 | ]
642 | },
643 | {
644 | "cell_type": "markdown",
645 | "metadata": {},
646 | "source": [
647 | "
"
648 | ]
649 | },
650 | {
651 | "cell_type": "code",
652 | "execution_count": 13,
653 | "metadata": {},
654 | "outputs": [
655 | {
656 | "name": "stdout",
657 | "output_type": "stream",
658 | "text": [
659 | " * mssql+pyodbc://abhat:***@sqldb1\n",
660 | " mssql+pyodbc://dstran:***@sqldb\n",
661 | "Done.\n"
662 | ]
663 | },
664 | {
665 | "data": {
666 | "text/html": [
667 | "\n",
668 | " \n",
669 | " SpecialOfferID | \n",
670 | " Description | \n",
671 | " DiscountPct | \n",
672 | " Type | \n",
673 | " Category | \n",
674 | " StartDate | \n",
675 | " EndDate | \n",
676 | " MinQty | \n",
677 | " MaxQty | \n",
678 | " rowguid | \n",
679 | " ModifiedDate | \n",
680 | "
\n",
681 | " \n",
682 | " 1 | \n",
683 | " No Discount | \n",
684 | " 0.0000 | \n",
685 | " No Discount | \n",
686 | " No Discount | \n",
687 | " 2011-05-01 00:00:00 | \n",
688 | " 2014-11-30 00:00:00 | \n",
689 | " 0 | \n",
690 | " None | \n",
691 | " 0290C4F5-191F-4337-AB6B-0A2DDE03CBF9 | \n",
692 | " 2011-04-01 00:00:00 | \n",
693 | "
\n",
694 | " \n",
695 | " 2 | \n",
696 | " Volume Discount 11 to 14 | \n",
697 | " 0.0200 | \n",
698 | " Volume Discount | \n",
699 | " Reseller | \n",
700 | " 2011-05-31 00:00:00 | \n",
701 | " 2014-05-30 00:00:00 | \n",
702 | " 11 | \n",
703 | " 14 | \n",
704 | " D7542EE7-15DB-4541-985C-5CC27AEF26D6 | \n",
705 | " 2011-05-01 00:00:00 | \n",
706 | "
\n",
707 | " \n",
708 | " 3 | \n",
709 | " Volume Discount 15 to 24 | \n",
710 | " 0.0500 | \n",
711 | " Volume Discount | \n",
712 | " Reseller | \n",
713 | " 2011-05-31 00:00:00 | \n",
714 | " 2014-05-30 00:00:00 | \n",
715 | " 15 | \n",
716 | " 24 | \n",
717 | " 4BDBCC01-8CF7-40A9-B643-40EC5B717491 | \n",
718 | " 2011-05-01 00:00:00 | \n",
719 | "
\n",
720 | " \n",
721 | " 4 | \n",
722 | " Volume Discount 25 to 40 | \n",
723 | " 0.1000 | \n",
724 | " Volume Discount | \n",
725 | " Reseller | \n",
726 | " 2011-05-31 00:00:00 | \n",
727 | " 2014-05-30 00:00:00 | \n",
728 | " 25 | \n",
729 | " 40 | \n",
730 | " 504B5E85-8F3F-4EBC-9E1D-C1BC5DEA9AA8 | \n",
731 | " 2011-05-01 00:00:00 | \n",
732 | "
\n",
733 | " \n",
734 | " 5 | \n",
735 | " Volume Discount 41 to 60 | \n",
736 | " 0.1500 | \n",
737 | " Volume Discount | \n",
738 | " Reseller | \n",
739 | " 2011-05-31 00:00:00 | \n",
740 | " 2014-05-30 00:00:00 | \n",
741 | " 41 | \n",
742 | " 60 | \n",
743 | " 677E1D9D-944F-4E81-90E8-47EB0A82D48C | \n",
744 | " 2011-05-01 00:00:00 | \n",
745 | "
\n",
746 | " \n",
747 | " 6 | \n",
748 | " Volume Discount over 60 | \n",
749 | " 0.2000 | \n",
750 | " Volume Discount | \n",
751 | " Reseller | \n",
752 | " 2011-05-31 00:00:00 | \n",
753 | " 2014-05-30 00:00:00 | \n",
754 | " 61 | \n",
755 | " None | \n",
756 | " 8157F569-4E8D-46B6-9347-5D0F726A9439 | \n",
757 | " 2011-05-01 00:00:00 | \n",
758 | "
\n",
759 | " \n",
760 | " 7 | \n",
761 | " Mountain-100 Clearance Sale | \n",
762 | " 0.3500 | \n",
763 | " Discontinued Product | \n",
764 | " Reseller | \n",
765 | " 2012-04-13 00:00:00 | \n",
766 | " 2012-05-29 00:00:00 | \n",
767 | " 0 | \n",
768 | " None | \n",
769 | " 7DF15BF5-6C05-47E7-80A4-22BD1CE59A72 | \n",
770 | " 2012-03-14 00:00:00 | \n",
771 | "
\n",
772 | " \n",
773 | " 8 | \n",
774 | " Sport Helmet Discount-2002 | \n",
775 | " 0.1000 | \n",
776 | " Seasonal Discount | \n",
777 | " Reseller | \n",
778 | " 2012-05-30 00:00:00 | \n",
779 | " 2012-06-29 00:00:00 | \n",
780 | " 0 | \n",
781 | " None | \n",
782 | " 20C5D2CC-A38F-48F8-AC9A-8F15943E52AE | \n",
783 | " 2012-04-30 00:00:00 | \n",
784 | "
\n",
785 | " \n",
786 | " 9 | \n",
787 | " Road-650 Overstock | \n",
788 | " 0.3000 | \n",
789 | " Excess Inventory | \n",
790 | " Reseller | \n",
791 | " 2012-05-30 00:00:00 | \n",
792 | " 2012-07-30 00:00:00 | \n",
793 | " 0 | \n",
794 | " None | \n",
795 | " 0CF8472B-F9E6-4945-9E09-549D7DDE2198 | \n",
796 | " 2012-04-30 00:00:00 | \n",
797 | "
\n",
798 | " \n",
799 | " 10 | \n",
800 | " Mountain Tire Sale | \n",
801 | " 0.5000 | \n",
802 | " Excess Inventory | \n",
803 | " Customer | \n",
804 | " 2013-05-14 00:00:00 | \n",
805 | " 2013-07-29 00:00:00 | \n",
806 | " 0 | \n",
807 | " None | \n",
808 | " 220444AD-2EF3-4E4C-87E9-3AA6EE39A877 | \n",
809 | " 2013-04-14 00:00:00 | \n",
810 | "
\n",
811 | "
"
812 | ],
813 | "text/plain": [
814 | "[(1, 'No Discount', Decimal('0.0000'), 'No Discount', 'No Discount', datetime.datetime(2011, 5, 1, 0, 0), datetime.datetime(2014, 11, 30, 0, 0), 0, None, '0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', datetime.datetime(2011, 4, 1, 0, 0)),\n",
815 | " (2, 'Volume Discount 11 to 14', Decimal('0.0200'), 'Volume Discount', 'Reseller', datetime.datetime(2011, 5, 31, 0, 0), datetime.datetime(2014, 5, 30, 0, 0), 11, 14, 'D7542EE7-15DB-4541-985C-5CC27AEF26D6', datetime.datetime(2011, 5, 1, 0, 0)),\n",
816 | " (3, 'Volume Discount 15 to 24', Decimal('0.0500'), 'Volume Discount', 'Reseller', datetime.datetime(2011, 5, 31, 0, 0), datetime.datetime(2014, 5, 30, 0, 0), 15, 24, '4BDBCC01-8CF7-40A9-B643-40EC5B717491', datetime.datetime(2011, 5, 1, 0, 0)),\n",
817 | " (4, 'Volume Discount 25 to 40', Decimal('0.1000'), 'Volume Discount', 'Reseller', datetime.datetime(2011, 5, 31, 0, 0), datetime.datetime(2014, 5, 30, 0, 0), 25, 40, '504B5E85-8F3F-4EBC-9E1D-C1BC5DEA9AA8', datetime.datetime(2011, 5, 1, 0, 0)),\n",
818 | " (5, 'Volume Discount 41 to 60', Decimal('0.1500'), 'Volume Discount', 'Reseller', datetime.datetime(2011, 5, 31, 0, 0), datetime.datetime(2014, 5, 30, 0, 0), 41, 60, '677E1D9D-944F-4E81-90E8-47EB0A82D48C', datetime.datetime(2011, 5, 1, 0, 0)),\n",
819 | " (6, 'Volume Discount over 60', Decimal('0.2000'), 'Volume Discount', 'Reseller', datetime.datetime(2011, 5, 31, 0, 0), datetime.datetime(2014, 5, 30, 0, 0), 61, None, '8157F569-4E8D-46B6-9347-5D0F726A9439', datetime.datetime(2011, 5, 1, 0, 0)),\n",
820 | " (7, 'Mountain-100 Clearance Sale', Decimal('0.3500'), 'Discontinued Product', 'Reseller', datetime.datetime(2012, 4, 13, 0, 0), datetime.datetime(2012, 5, 29, 0, 0), 0, None, '7DF15BF5-6C05-47E7-80A4-22BD1CE59A72', datetime.datetime(2012, 3, 14, 0, 0)),\n",
821 | " (8, 'Sport Helmet Discount-2002', Decimal('0.1000'), 'Seasonal Discount', 'Reseller', datetime.datetime(2012, 5, 30, 0, 0), datetime.datetime(2012, 6, 29, 0, 0), 0, None, '20C5D2CC-A38F-48F8-AC9A-8F15943E52AE', datetime.datetime(2012, 4, 30, 0, 0)),\n",
822 | " (9, 'Road-650 Overstock', Decimal('0.3000'), 'Excess Inventory', 'Reseller', datetime.datetime(2012, 5, 30, 0, 0), datetime.datetime(2012, 7, 30, 0, 0), 0, None, '0CF8472B-F9E6-4945-9E09-549D7DDE2198', datetime.datetime(2012, 4, 30, 0, 0)),\n",
823 | " (10, 'Mountain Tire Sale', Decimal('0.5000'), 'Excess Inventory', 'Customer', datetime.datetime(2013, 5, 14, 0, 0), datetime.datetime(2013, 7, 29, 0, 0), 0, None, '220444AD-2EF3-4E4C-87E9-3AA6EE39A877', datetime.datetime(2013, 4, 14, 0, 0))]"
824 | ]
825 | },
826 | "execution_count": 13,
827 | "metadata": {},
828 | "output_type": "execute_result"
829 | }
830 | ],
831 | "source": [
832 | "%%sql\n",
833 | "\n",
834 | "select top 10 * from Sales.SpecialOffer"
835 | ]
836 | },
837 | {
838 | "cell_type": "markdown",
839 | "metadata": {},
840 | "source": [
841 | "### Connect to ORACLE Database using sqlalchemy"
842 | ]
843 | },
844 | {
845 | "cell_type": "markdown",
846 | "metadata": {},
847 | "source": [
848 | "Sample Database Used - https://www.oracletutorial.com/getting-started/oracle-sample-database/"
849 | ]
850 | },
851 | {
852 | "cell_type": "markdown",
853 | "metadata": {},
854 | "source": [
855 | "__This is how my connection looks like in SQL developer :-__"
856 | ]
857 | },
858 | {
859 | "cell_type": "markdown",
860 | "metadata": {},
861 | "source": [
862 | "
"
863 | ]
864 | },
865 | {
866 | "cell_type": "code",
867 | "execution_count": 14,
868 | "metadata": {},
869 | "outputs": [],
870 | "source": [
871 | "engine_ora = sqlalchemy.create_engine('oracle://c##abhat:abhat@localhost:1521/orcl')"
872 | ]
873 | },
874 | {
875 | "cell_type": "code",
876 | "execution_count": 15,
877 | "metadata": {},
878 | "outputs": [
879 | {
880 | "name": "stdout",
881 | "output_type": "stream",
882 | "text": [
883 | "connecting with engine Engine(oracle://c##abhat:***@localhost:1521/orcl)\n"
884 | ]
885 | }
886 | ],
887 | "source": [
888 | "print(\"connecting with engine \" + str(engine_ora))"
889 | ]
890 | },
891 | {
892 | "cell_type": "code",
893 | "execution_count": 16,
894 | "metadata": {},
895 | "outputs": [
896 | {
897 | "name": "stdout",
898 | "output_type": "stream",
899 | "text": [
900 | "['regions', 'countries', 'locations', 'warehouses', 'employees', 'product_categories', 'products', 'customers', 'contacts', 'orders', 'order_items', 'inventories']\n"
901 | ]
902 | }
903 | ],
904 | "source": [
905 | "print(engine_ora.table_names())"
906 | ]
907 | },
908 | {
909 | "cell_type": "code",
910 | "execution_count": 17,
911 | "metadata": {},
912 | "outputs": [],
913 | "source": [
914 | "con_ORA = engine_ora.connect()"
915 | ]
916 | },
917 | {
918 | "cell_type": "code",
919 | "execution_count": 18,
920 | "metadata": {},
921 | "outputs": [
922 | {
923 | "data": {
924 | "text/html": [
925 | "\n",
926 | "\n",
939 | "
\n",
940 | " \n",
941 | " \n",
942 | " | \n",
943 | " contact_id | \n",
944 | " first_name | \n",
945 | " last_name | \n",
946 | " email | \n",
947 | " phone | \n",
948 | " customer_id | \n",
949 | "
\n",
950 | " \n",
951 | " \n",
952 | " \n",
953 | " 0 | \n",
954 | " 208 | \n",
955 | " Stephaine | \n",
956 | " Booker | \n",
957 | " stephaine.booker@tsocorp.com | \n",
958 | " +39 55 012 4559 | \n",
959 | " 208 | \n",
960 | "
\n",
961 | " \n",
962 | " 1 | \n",
963 | " 209 | \n",
964 | " Emilie | \n",
965 | " Parsons | \n",
966 | " emilie.parsons@timewarner.com | \n",
967 | " +39 10 012 4363 | \n",
968 | " 209 | \n",
969 | "
\n",
970 | " \n",
971 | " 2 | \n",
972 | " 210 | \n",
973 | " Jaleesa | \n",
974 | " Bowen | \n",
975 | " jaleesa.bowen@cstbrands.com | \n",
976 | " +66 76 012 4633 | \n",
977 | " 210 | \n",
978 | "
\n",
979 | " \n",
980 | " 3 | \n",
981 | " 211 | \n",
982 | " Jeannie | \n",
983 | " Poole | \n",
984 | " jeannie.poole@aboutmcdonalds.com | \n",
985 | " +91 80 012 4637 | \n",
986 | " 211 | \n",
987 | "
\n",
988 | " \n",
989 | " 4 | \n",
990 | " 212 | \n",
991 | " Adrienne | \n",
992 | " Lang | \n",
993 | " adrienne.lang@qualcomm.com | \n",
994 | " +39 2 012 4771 | \n",
995 | " 212 | \n",
996 | "
\n",
997 | " \n",
998 | " ... | \n",
999 | " ... | \n",
1000 | " ... | \n",
1001 | " ... | \n",
1002 | " ... | \n",
1003 | " ... | \n",
1004 | " ... | \n",
1005 | "
\n",
1006 | " \n",
1007 | " 314 | \n",
1008 | " 203 | \n",
1009 | " Vella | \n",
1010 | " Hancock | \n",
1011 | " vella.hancock@pmi.com | \n",
1012 | " +39 49 012 4375 | \n",
1013 | " 203 | \n",
1014 | "
\n",
1015 | " \n",
1016 | " 315 | \n",
1017 | " 204 | \n",
1018 | " Retta | \n",
1019 | " Martinez | \n",
1020 | " retta.martinez@riteaid.com | \n",
1021 | " +39 49 012 4377 | \n",
1022 | " 204 | \n",
1023 | "
\n",
1024 | " \n",
1025 | " 316 | \n",
1026 | " 205 | \n",
1027 | " Annelle | \n",
1028 | " Lawrence | \n",
1029 | " annelle.lawrence@techdata.com | \n",
1030 | " +39 10 012 4379 | \n",
1031 | " 205 | \n",
1032 | "
\n",
1033 | " \n",
1034 | " 317 | \n",
1035 | " 206 | \n",
1036 | " Sherron | \n",
1037 | " Simon | \n",
1038 | " sherron.simon@ally.com | \n",
1039 | " +39 10 012 4381 | \n",
1040 | " 206 | \n",
1041 | "
\n",
1042 | " \n",
1043 | " 318 | \n",
1044 | " 207 | \n",
1045 | " Carita | \n",
1046 | " Mcintyre | \n",
1047 | " carita.mcintyre@northwesternmutual.com | \n",
1048 | " +86 10 012 4165 | \n",
1049 | " 207 | \n",
1050 | "
\n",
1051 | " \n",
1052 | "
\n",
1053 | "
319 rows × 6 columns
\n",
1054 | "
"
1055 | ],
1056 | "text/plain": [
1057 | " contact_id first_name last_name email \\\n",
1058 | "0 208 Stephaine Booker stephaine.booker@tsocorp.com \n",
1059 | "1 209 Emilie Parsons emilie.parsons@timewarner.com \n",
1060 | "2 210 Jaleesa Bowen jaleesa.bowen@cstbrands.com \n",
1061 | "3 211 Jeannie Poole jeannie.poole@aboutmcdonalds.com \n",
1062 | "4 212 Adrienne Lang adrienne.lang@qualcomm.com \n",
1063 | ".. ... ... ... ... \n",
1064 | "314 203 Vella Hancock vella.hancock@pmi.com \n",
1065 | "315 204 Retta Martinez retta.martinez@riteaid.com \n",
1066 | "316 205 Annelle Lawrence annelle.lawrence@techdata.com \n",
1067 | "317 206 Sherron Simon sherron.simon@ally.com \n",
1068 | "318 207 Carita Mcintyre carita.mcintyre@northwesternmutual.com \n",
1069 | "\n",
1070 | " phone customer_id \n",
1071 | "0 +39 55 012 4559 208 \n",
1072 | "1 +39 10 012 4363 209 \n",
1073 | "2 +66 76 012 4633 210 \n",
1074 | "3 +91 80 012 4637 211 \n",
1075 | "4 +39 2 012 4771 212 \n",
1076 | ".. ... ... \n",
1077 | "314 +39 49 012 4375 203 \n",
1078 | "315 +39 49 012 4377 204 \n",
1079 | "316 +39 10 012 4379 205 \n",
1080 | "317 +39 10 012 4381 206 \n",
1081 | "318 +86 10 012 4165 207 \n",
1082 | "\n",
1083 | "[319 rows x 6 columns]"
1084 | ]
1085 | },
1086 | "execution_count": 18,
1087 | "metadata": {},
1088 | "output_type": "execute_result"
1089 | }
1090 | ],
1091 | "source": [
1092 | "query = \"select * from CONTACTS\"\n",
1093 | "df_ora = pd.read_sql_query(query, con_ORA)\n",
1094 | "df_ora"
1095 | ]
1096 | },
1097 | {
1098 | "cell_type": "markdown",
1099 | "metadata": {},
1100 | "source": [
1101 | "### Using cx_oracle"
1102 | ]
1103 | },
1104 | {
1105 | "cell_type": "code",
1106 | "execution_count": 54,
1107 | "metadata": {},
1108 | "outputs": [],
1109 | "source": [
1110 | "engine_ora1 = sqlalchemy.create_engine('oracle+cx_oracle://c##abhat:abhat@localhost:1521/orcl')"
1111 | ]
1112 | },
1113 | {
1114 | "cell_type": "code",
1115 | "execution_count": 55,
1116 | "metadata": {},
1117 | "outputs": [
1118 | {
1119 | "name": "stdout",
1120 | "output_type": "stream",
1121 | "text": [
1122 | "connecting with engine Engine(oracle+cx_oracle://c##abhat:***@localhost:1521/orcl)\n"
1123 | ]
1124 | }
1125 | ],
1126 | "source": [
1127 | "print(\"connecting with engine \" + str(engine_ora1))"
1128 | ]
1129 | },
1130 | {
1131 | "cell_type": "code",
1132 | "execution_count": 56,
1133 | "metadata": {},
1134 | "outputs": [
1135 | {
1136 | "name": "stdout",
1137 | "output_type": "stream",
1138 | "text": [
1139 | "['regions', 'countries', 'locations', 'warehouses', 'employees', 'product_categories', 'products', 'customers', 'contacts', 'orders', 'order_items', 'inventories']\n"
1140 | ]
1141 | }
1142 | ],
1143 | "source": [
1144 | "print(engine_ora1.table_names())"
1145 | ]
1146 | },
1147 | {
1148 | "cell_type": "code",
1149 | "execution_count": 57,
1150 | "metadata": {},
1151 | "outputs": [],
1152 | "source": [
1153 | "con_ORA1 = engine_ora1.connect()"
1154 | ]
1155 | },
1156 | {
1157 | "cell_type": "code",
1158 | "execution_count": 58,
1159 | "metadata": {},
1160 | "outputs": [
1161 | {
1162 | "data": {
1163 | "text/html": [
1164 | "\n",
1165 | "\n",
1178 | "
\n",
1179 | " \n",
1180 | " \n",
1181 | " | \n",
1182 | " contact_id | \n",
1183 | " first_name | \n",
1184 | " last_name | \n",
1185 | " email | \n",
1186 | " phone | \n",
1187 | " customer_id | \n",
1188 | "
\n",
1189 | " \n",
1190 | " \n",
1191 | " \n",
1192 | " 0 | \n",
1193 | " 208 | \n",
1194 | " Stephaine | \n",
1195 | " Booker | \n",
1196 | " stephaine.booker@tsocorp.com | \n",
1197 | " +39 55 012 4559 | \n",
1198 | " 208 | \n",
1199 | "
\n",
1200 | " \n",
1201 | " 1 | \n",
1202 | " 209 | \n",
1203 | " Emilie | \n",
1204 | " Parsons | \n",
1205 | " emilie.parsons@timewarner.com | \n",
1206 | " +39 10 012 4363 | \n",
1207 | " 209 | \n",
1208 | "
\n",
1209 | " \n",
1210 | " 2 | \n",
1211 | " 210 | \n",
1212 | " Jaleesa | \n",
1213 | " Bowen | \n",
1214 | " jaleesa.bowen@cstbrands.com | \n",
1215 | " +66 76 012 4633 | \n",
1216 | " 210 | \n",
1217 | "
\n",
1218 | " \n",
1219 | " 3 | \n",
1220 | " 211 | \n",
1221 | " Jeannie | \n",
1222 | " Poole | \n",
1223 | " jeannie.poole@aboutmcdonalds.com | \n",
1224 | " +91 80 012 4637 | \n",
1225 | " 211 | \n",
1226 | "
\n",
1227 | " \n",
1228 | " 4 | \n",
1229 | " 212 | \n",
1230 | " Adrienne | \n",
1231 | " Lang | \n",
1232 | " adrienne.lang@qualcomm.com | \n",
1233 | " +39 2 012 4771 | \n",
1234 | " 212 | \n",
1235 | "
\n",
1236 | " \n",
1237 | " ... | \n",
1238 | " ... | \n",
1239 | " ... | \n",
1240 | " ... | \n",
1241 | " ... | \n",
1242 | " ... | \n",
1243 | " ... | \n",
1244 | "
\n",
1245 | " \n",
1246 | " 314 | \n",
1247 | " 203 | \n",
1248 | " Vella | \n",
1249 | " Hancock | \n",
1250 | " vella.hancock@pmi.com | \n",
1251 | " +39 49 012 4375 | \n",
1252 | " 203 | \n",
1253 | "
\n",
1254 | " \n",
1255 | " 315 | \n",
1256 | " 204 | \n",
1257 | " Retta | \n",
1258 | " Martinez | \n",
1259 | " retta.martinez@riteaid.com | \n",
1260 | " +39 49 012 4377 | \n",
1261 | " 204 | \n",
1262 | "
\n",
1263 | " \n",
1264 | " 316 | \n",
1265 | " 205 | \n",
1266 | " Annelle | \n",
1267 | " Lawrence | \n",
1268 | " annelle.lawrence@techdata.com | \n",
1269 | " +39 10 012 4379 | \n",
1270 | " 205 | \n",
1271 | "
\n",
1272 | " \n",
1273 | " 317 | \n",
1274 | " 206 | \n",
1275 | " Sherron | \n",
1276 | " Simon | \n",
1277 | " sherron.simon@ally.com | \n",
1278 | " +39 10 012 4381 | \n",
1279 | " 206 | \n",
1280 | "
\n",
1281 | " \n",
1282 | " 318 | \n",
1283 | " 207 | \n",
1284 | " Carita | \n",
1285 | " Mcintyre | \n",
1286 | " carita.mcintyre@northwesternmutual.com | \n",
1287 | " +86 10 012 4165 | \n",
1288 | " 207 | \n",
1289 | "
\n",
1290 | " \n",
1291 | "
\n",
1292 | "
319 rows × 6 columns
\n",
1293 | "
"
1294 | ],
1295 | "text/plain": [
1296 | " contact_id first_name last_name email \\\n",
1297 | "0 208 Stephaine Booker stephaine.booker@tsocorp.com \n",
1298 | "1 209 Emilie Parsons emilie.parsons@timewarner.com \n",
1299 | "2 210 Jaleesa Bowen jaleesa.bowen@cstbrands.com \n",
1300 | "3 211 Jeannie Poole jeannie.poole@aboutmcdonalds.com \n",
1301 | "4 212 Adrienne Lang adrienne.lang@qualcomm.com \n",
1302 | ".. ... ... ... ... \n",
1303 | "314 203 Vella Hancock vella.hancock@pmi.com \n",
1304 | "315 204 Retta Martinez retta.martinez@riteaid.com \n",
1305 | "316 205 Annelle Lawrence annelle.lawrence@techdata.com \n",
1306 | "317 206 Sherron Simon sherron.simon@ally.com \n",
1307 | "318 207 Carita Mcintyre carita.mcintyre@northwesternmutual.com \n",
1308 | "\n",
1309 | " phone customer_id \n",
1310 | "0 +39 55 012 4559 208 \n",
1311 | "1 +39 10 012 4363 209 \n",
1312 | "2 +66 76 012 4633 210 \n",
1313 | "3 +91 80 012 4637 211 \n",
1314 | "4 +39 2 012 4771 212 \n",
1315 | ".. ... ... \n",
1316 | "314 +39 49 012 4375 203 \n",
1317 | "315 +39 49 012 4377 204 \n",
1318 | "316 +39 10 012 4379 205 \n",
1319 | "317 +39 10 012 4381 206 \n",
1320 | "318 +86 10 012 4165 207 \n",
1321 | "\n",
1322 | "[319 rows x 6 columns]"
1323 | ]
1324 | },
1325 | "execution_count": 58,
1326 | "metadata": {},
1327 | "output_type": "execute_result"
1328 | }
1329 | ],
1330 | "source": [
1331 | "query = \"select * from CONTACTS\"\n",
1332 | "df_ora1 = pd.read_sql_query(query, con_ORA1)\n",
1333 | "df_ora1"
1334 | ]
1335 | },
1336 | {
1337 | "cell_type": "markdown",
1338 | "metadata": {},
1339 | "source": [
1340 | "### Connect to ORACLE Database using ipython-sql"
1341 | ]
1342 | },
1343 | {
1344 | "cell_type": "code",
1345 | "execution_count": 19,
1346 | "metadata": {},
1347 | "outputs": [
1348 | {
1349 | "name": "stdout",
1350 | "output_type": "stream",
1351 | "text": [
1352 | "The sql extension is already loaded. To reload it, use:\n",
1353 | " %reload_ext sql\n"
1354 | ]
1355 | }
1356 | ],
1357 | "source": [
1358 | "%load_ext sql\n",
1359 | "%sql \"oracle://c##abhat:abhat@localhost:1521/orcl\""
1360 | ]
1361 | },
1362 | {
1363 | "cell_type": "code",
1364 | "execution_count": 20,
1365 | "metadata": {},
1366 | "outputs": [
1367 | {
1368 | "name": "stdout",
1369 | "output_type": "stream",
1370 | "text": [
1371 | " mssql+pyodbc://abhat:***@sqldb1\n",
1372 | " mssql+pyodbc://dstran:***@sqldb\n",
1373 | " * oracle://c##abhat:***@localhost:1521/orcl\n",
1374 | "0 rows affected.\n"
1375 | ]
1376 | },
1377 | {
1378 | "data": {
1379 | "text/html": [
1380 | "\n",
1381 | " \n",
1382 | " contact_id | \n",
1383 | " first_name | \n",
1384 | " last_name | \n",
1385 | " email | \n",
1386 | " phone | \n",
1387 | " customer_id | \n",
1388 | "
\n",
1389 | " \n",
1390 | " 208 | \n",
1391 | " Stephaine | \n",
1392 | " Booker | \n",
1393 | " stephaine.booker@tsocorp.com | \n",
1394 | " +39 55 012 4559 | \n",
1395 | " 208 | \n",
1396 | "
\n",
1397 | " \n",
1398 | " 209 | \n",
1399 | " Emilie | \n",
1400 | " Parsons | \n",
1401 | " emilie.parsons@timewarner.com | \n",
1402 | " +39 10 012 4363 | \n",
1403 | " 209 | \n",
1404 | "
\n",
1405 | " \n",
1406 | " 210 | \n",
1407 | " Jaleesa | \n",
1408 | " Bowen | \n",
1409 | " jaleesa.bowen@cstbrands.com | \n",
1410 | " +66 76 012 4633 | \n",
1411 | " 210 | \n",
1412 | "
\n",
1413 | " \n",
1414 | " 211 | \n",
1415 | " Jeannie | \n",
1416 | " Poole | \n",
1417 | " jeannie.poole@aboutmcdonalds.com | \n",
1418 | " +91 80 012 4637 | \n",
1419 | " 211 | \n",
1420 | "
\n",
1421 | " \n",
1422 | " 212 | \n",
1423 | " Adrienne | \n",
1424 | " Lang | \n",
1425 | " adrienne.lang@qualcomm.com | \n",
1426 | " +39 2 012 4771 | \n",
1427 | " 212 | \n",
1428 | "
\n",
1429 | " \n",
1430 | " 213 | \n",
1431 | " Jess | \n",
1432 | " Nguyen | \n",
1433 | " jess.nguyen@searsholdings.com | \n",
1434 | " +39 2 012 4773 | \n",
1435 | " 213 | \n",
1436 | "
\n",
1437 | " \n",
1438 | " 214 | \n",
1439 | " Tandy | \n",
1440 | " House | \n",
1441 | " tandy.house@ebay.com | \n",
1442 | " +39 2 012 4775 | \n",
1443 | " 214 | \n",
1444 | "
\n",
1445 | " \n",
1446 | " 215 | \n",
1447 | " Herman | \n",
1448 | " Stokes | \n",
1449 | " herman.stokes@capitalone.com | \n",
1450 | " +39 49 012 4777 | \n",
1451 | " 215 | \n",
1452 | "
\n",
1453 | " \n",
1454 | " 216 | \n",
1455 | " Keesha | \n",
1456 | " Lambert | \n",
1457 | " keesha.lambert@emc.com | \n",
1458 | " +39 49 012 4779 | \n",
1459 | " 216 | \n",
1460 | "
\n",
1461 | " \n",
1462 | " 217 | \n",
1463 | " Lauren | \n",
1464 | " Williamson | \n",
1465 | " lauren.williamson@usaa.com | \n",
1466 | " +39 49 012 4781 | \n",
1467 | " 217 | \n",
1468 | "
\n",
1469 | "
"
1470 | ],
1471 | "text/plain": [
1472 | "[(208, 'Stephaine', 'Booker', 'stephaine.booker@tsocorp.com', '+39 55 012 4559', 208),\n",
1473 | " (209, 'Emilie', 'Parsons', 'emilie.parsons@timewarner.com', '+39 10 012 4363', 209),\n",
1474 | " (210, 'Jaleesa', 'Bowen', 'jaleesa.bowen@cstbrands.com', '+66 76 012 4633', 210),\n",
1475 | " (211, 'Jeannie', 'Poole', 'jeannie.poole@aboutmcdonalds.com', '+91 80 012 4637', 211),\n",
1476 | " (212, 'Adrienne', 'Lang', 'adrienne.lang@qualcomm.com', '+39 2 012 4771', 212),\n",
1477 | " (213, 'Jess', 'Nguyen', 'jess.nguyen@searsholdings.com', '+39 2 012 4773', 213),\n",
1478 | " (214, 'Tandy', 'House', 'tandy.house@ebay.com', '+39 2 012 4775', 214),\n",
1479 | " (215, 'Herman', 'Stokes', 'herman.stokes@capitalone.com', '+39 49 012 4777', 215),\n",
1480 | " (216, 'Keesha', 'Lambert', 'keesha.lambert@emc.com', '+39 49 012 4779', 216),\n",
1481 | " (217, 'Lauren', 'Williamson', 'lauren.williamson@usaa.com', '+39 49 012 4781', 217)]"
1482 | ]
1483 | },
1484 | "execution_count": 20,
1485 | "metadata": {},
1486 | "output_type": "execute_result"
1487 | }
1488 | ],
1489 | "source": [
1490 | "%%sql\n",
1491 | "select * from contacts where rownum < 11"
1492 | ]
1493 | },
1494 | {
1495 | "cell_type": "markdown",
1496 | "metadata": {},
1497 | "source": [
1498 | "### Connect to MySQL Database using sqlalchemy"
1499 | ]
1500 | },
1501 | {
1502 | "cell_type": "markdown",
1503 | "metadata": {},
1504 | "source": [
1505 | "__This is how my Schema looks like in MySQL Workbench :-__"
1506 | ]
1507 | },
1508 | {
1509 | "cell_type": "markdown",
1510 | "metadata": {},
1511 | "source": [
1512 | "
"
1513 | ]
1514 | },
1515 | {
1516 | "cell_type": "code",
1517 | "execution_count": 21,
1518 | "metadata": {},
1519 | "outputs": [],
1520 | "source": [
1521 | "engine_mysql = sqlalchemy.create_engine('mysql+pymysql://root:root@localhost:3306/sakila')"
1522 | ]
1523 | },
1524 | {
1525 | "cell_type": "code",
1526 | "execution_count": 22,
1527 | "metadata": {},
1528 | "outputs": [
1529 | {
1530 | "name": "stdout",
1531 | "output_type": "stream",
1532 | "text": [
1533 | "connecting with engine Engine(mysql+pymysql://root:***@localhost:3306/sakila)\n"
1534 | ]
1535 | }
1536 | ],
1537 | "source": [
1538 | "print(\"connecting with engine \" + str(engine_mysql))"
1539 | ]
1540 | },
1541 | {
1542 | "cell_type": "code",
1543 | "execution_count": 23,
1544 | "metadata": {},
1545 | "outputs": [
1546 | {
1547 | "name": "stdout",
1548 | "output_type": "stream",
1549 | "text": [
1550 | "['actor', 'address', 'category', 'city', 'country', 'customer', 'film', 'film_actor', 'film_category', 'film_text', 'inventory', 'language', 'payment', 'rental', 'staff', 'store']\n"
1551 | ]
1552 | }
1553 | ],
1554 | "source": [
1555 | "print(engine_mysql.table_names())"
1556 | ]
1557 | },
1558 | {
1559 | "cell_type": "code",
1560 | "execution_count": 24,
1561 | "metadata": {},
1562 | "outputs": [],
1563 | "source": [
1564 | "con_mysql = engine_mysql.connect()"
1565 | ]
1566 | },
1567 | {
1568 | "cell_type": "code",
1569 | "execution_count": 25,
1570 | "metadata": {},
1571 | "outputs": [
1572 | {
1573 | "data": {
1574 | "text/html": [
1575 | "\n",
1576 | "\n",
1589 | "
\n",
1590 | " \n",
1591 | " \n",
1592 | " | \n",
1593 | " category_id | \n",
1594 | " name | \n",
1595 | " last_update | \n",
1596 | "
\n",
1597 | " \n",
1598 | " \n",
1599 | " \n",
1600 | " 0 | \n",
1601 | " 1 | \n",
1602 | " Action | \n",
1603 | " 2006-02-15 04:46:27 | \n",
1604 | "
\n",
1605 | " \n",
1606 | " 1 | \n",
1607 | " 2 | \n",
1608 | " Animation | \n",
1609 | " 2006-02-15 04:46:27 | \n",
1610 | "
\n",
1611 | " \n",
1612 | " 2 | \n",
1613 | " 3 | \n",
1614 | " Children | \n",
1615 | " 2006-02-15 04:46:27 | \n",
1616 | "
\n",
1617 | " \n",
1618 | " 3 | \n",
1619 | " 4 | \n",
1620 | " Classics | \n",
1621 | " 2006-02-15 04:46:27 | \n",
1622 | "
\n",
1623 | " \n",
1624 | " 4 | \n",
1625 | " 5 | \n",
1626 | " Comedy | \n",
1627 | " 2006-02-15 04:46:27 | \n",
1628 | "
\n",
1629 | " \n",
1630 | " 5 | \n",
1631 | " 6 | \n",
1632 | " Documentary | \n",
1633 | " 2006-02-15 04:46:27 | \n",
1634 | "
\n",
1635 | " \n",
1636 | " 6 | \n",
1637 | " 7 | \n",
1638 | " Drama | \n",
1639 | " 2006-02-15 04:46:27 | \n",
1640 | "
\n",
1641 | " \n",
1642 | " 7 | \n",
1643 | " 8 | \n",
1644 | " Family | \n",
1645 | " 2006-02-15 04:46:27 | \n",
1646 | "
\n",
1647 | " \n",
1648 | " 8 | \n",
1649 | " 9 | \n",
1650 | " Foreign | \n",
1651 | " 2006-02-15 04:46:27 | \n",
1652 | "
\n",
1653 | " \n",
1654 | " 9 | \n",
1655 | " 10 | \n",
1656 | " Games | \n",
1657 | " 2006-02-15 04:46:27 | \n",
1658 | "
\n",
1659 | " \n",
1660 | " 10 | \n",
1661 | " 11 | \n",
1662 | " Horror | \n",
1663 | " 2006-02-15 04:46:27 | \n",
1664 | "
\n",
1665 | " \n",
1666 | " 11 | \n",
1667 | " 12 | \n",
1668 | " Music | \n",
1669 | " 2006-02-15 04:46:27 | \n",
1670 | "
\n",
1671 | " \n",
1672 | " 12 | \n",
1673 | " 13 | \n",
1674 | " New | \n",
1675 | " 2006-02-15 04:46:27 | \n",
1676 | "
\n",
1677 | " \n",
1678 | " 13 | \n",
1679 | " 14 | \n",
1680 | " Sci-Fi | \n",
1681 | " 2006-02-15 04:46:27 | \n",
1682 | "
\n",
1683 | " \n",
1684 | " 14 | \n",
1685 | " 15 | \n",
1686 | " Sports | \n",
1687 | " 2006-02-15 04:46:27 | \n",
1688 | "
\n",
1689 | " \n",
1690 | " 15 | \n",
1691 | " 16 | \n",
1692 | " Travel | \n",
1693 | " 2006-02-15 04:46:27 | \n",
1694 | "
\n",
1695 | " \n",
1696 | "
\n",
1697 | "
"
1698 | ],
1699 | "text/plain": [
1700 | " category_id name last_update\n",
1701 | "0 1 Action 2006-02-15 04:46:27\n",
1702 | "1 2 Animation 2006-02-15 04:46:27\n",
1703 | "2 3 Children 2006-02-15 04:46:27\n",
1704 | "3 4 Classics 2006-02-15 04:46:27\n",
1705 | "4 5 Comedy 2006-02-15 04:46:27\n",
1706 | "5 6 Documentary 2006-02-15 04:46:27\n",
1707 | "6 7 Drama 2006-02-15 04:46:27\n",
1708 | "7 8 Family 2006-02-15 04:46:27\n",
1709 | "8 9 Foreign 2006-02-15 04:46:27\n",
1710 | "9 10 Games 2006-02-15 04:46:27\n",
1711 | "10 11 Horror 2006-02-15 04:46:27\n",
1712 | "11 12 Music 2006-02-15 04:46:27\n",
1713 | "12 13 New 2006-02-15 04:46:27\n",
1714 | "13 14 Sci-Fi 2006-02-15 04:46:27\n",
1715 | "14 15 Sports 2006-02-15 04:46:27\n",
1716 | "15 16 Travel 2006-02-15 04:46:27"
1717 | ]
1718 | },
1719 | "execution_count": 25,
1720 | "metadata": {},
1721 | "output_type": "execute_result"
1722 | }
1723 | ],
1724 | "source": [
1725 | "query = \"select * from category\"\n",
1726 | "df_mysql = pd.read_sql_query(query, con_mysql)\n",
1727 | "df_mysql"
1728 | ]
1729 | },
1730 | {
1731 | "cell_type": "markdown",
1732 | "metadata": {},
1733 | "source": [
1734 | "### Connect to MySQL Database using ipython-sql"
1735 | ]
1736 | },
1737 | {
1738 | "cell_type": "markdown",
1739 | "metadata": {},
1740 | "source": [
1741 | "
"
1742 | ]
1743 | },
1744 | {
1745 | "cell_type": "code",
1746 | "execution_count": 1,
1747 | "metadata": {},
1748 | "outputs": [
1749 | {
1750 | "name": "stdout",
1751 | "output_type": "stream",
1752 | "text": [
1753 | "Connection info needed in SQLAlchemy format, example:\n",
1754 | " postgresql://username:password@hostname/dbname\n",
1755 | " or an existing connection: dict_keys([])\n",
1756 | "Could not parse rfc1738 URL from string '\"mysql+pymysql://root:root@localhost:3306/world\"'\n",
1757 | "Connection info needed in SQLAlchemy format, example:\n",
1758 | " postgresql://username:password@hostname/dbname\n",
1759 | " or an existing connection: dict_keys([])\n"
1760 | ]
1761 | }
1762 | ],
1763 | "source": [
1764 | "%load_ext sql\n",
1765 | "%sql \"mysql+pymysql://root:root@localhost:3306/world\""
1766 | ]
1767 | },
1768 | {
1769 | "cell_type": "code",
1770 | "execution_count": 27,
1771 | "metadata": {},
1772 | "outputs": [
1773 | {
1774 | "name": "stdout",
1775 | "output_type": "stream",
1776 | "text": [
1777 | " mssql+pyodbc://abhat:***@sqldb1\n",
1778 | " mssql+pyodbc://dstran:***@sqldb\n",
1779 | " * mysql+pymysql://root:***@localhost:3306/world\n",
1780 | " oracle://c##abhat:***@localhost:1521/orcl\n",
1781 | "20 rows affected.\n"
1782 | ]
1783 | },
1784 | {
1785 | "data": {
1786 | "text/html": [
1787 | "\n",
1788 | " \n",
1789 | " ID | \n",
1790 | " Name | \n",
1791 | " CountryCode | \n",
1792 | " District | \n",
1793 | " Population | \n",
1794 | "
\n",
1795 | " \n",
1796 | " 1 | \n",
1797 | " Kabul | \n",
1798 | " AFG | \n",
1799 | " Kabol | \n",
1800 | " 1780000 | \n",
1801 | "
\n",
1802 | " \n",
1803 | " 2 | \n",
1804 | " Qandahar | \n",
1805 | " AFG | \n",
1806 | " Qandahar | \n",
1807 | " 237500 | \n",
1808 | "
\n",
1809 | " \n",
1810 | " 3 | \n",
1811 | " Herat | \n",
1812 | " AFG | \n",
1813 | " Herat | \n",
1814 | " 186800 | \n",
1815 | "
\n",
1816 | " \n",
1817 | " 4 | \n",
1818 | " Mazar-e-Sharif | \n",
1819 | " AFG | \n",
1820 | " Balkh | \n",
1821 | " 127800 | \n",
1822 | "
\n",
1823 | " \n",
1824 | " 5 | \n",
1825 | " Amsterdam | \n",
1826 | " NLD | \n",
1827 | " Noord-Holland | \n",
1828 | " 731200 | \n",
1829 | "
\n",
1830 | " \n",
1831 | " 6 | \n",
1832 | " Rotterdam | \n",
1833 | " NLD | \n",
1834 | " Zuid-Holland | \n",
1835 | " 593321 | \n",
1836 | "
\n",
1837 | " \n",
1838 | " 7 | \n",
1839 | " Haag | \n",
1840 | " NLD | \n",
1841 | " Zuid-Holland | \n",
1842 | " 440900 | \n",
1843 | "
\n",
1844 | " \n",
1845 | " 8 | \n",
1846 | " Utrecht | \n",
1847 | " NLD | \n",
1848 | " Utrecht | \n",
1849 | " 234323 | \n",
1850 | "
\n",
1851 | " \n",
1852 | " 9 | \n",
1853 | " Eindhoven | \n",
1854 | " NLD | \n",
1855 | " Noord-Brabant | \n",
1856 | " 201843 | \n",
1857 | "
\n",
1858 | " \n",
1859 | " 10 | \n",
1860 | " Tilburg | \n",
1861 | " NLD | \n",
1862 | " Noord-Brabant | \n",
1863 | " 193238 | \n",
1864 | "
\n",
1865 | " \n",
1866 | " 11 | \n",
1867 | " Groningen | \n",
1868 | " NLD | \n",
1869 | " Groningen | \n",
1870 | " 172701 | \n",
1871 | "
\n",
1872 | " \n",
1873 | " 12 | \n",
1874 | " Breda | \n",
1875 | " NLD | \n",
1876 | " Noord-Brabant | \n",
1877 | " 160398 | \n",
1878 | "
\n",
1879 | " \n",
1880 | " 13 | \n",
1881 | " Apeldoorn | \n",
1882 | " NLD | \n",
1883 | " Gelderland | \n",
1884 | " 153491 | \n",
1885 | "
\n",
1886 | " \n",
1887 | " 14 | \n",
1888 | " Nijmegen | \n",
1889 | " NLD | \n",
1890 | " Gelderland | \n",
1891 | " 152463 | \n",
1892 | "
\n",
1893 | " \n",
1894 | " 15 | \n",
1895 | " Enschede | \n",
1896 | " NLD | \n",
1897 | " Overijssel | \n",
1898 | " 149544 | \n",
1899 | "
\n",
1900 | " \n",
1901 | " 16 | \n",
1902 | " Haarlem | \n",
1903 | " NLD | \n",
1904 | " Noord-Holland | \n",
1905 | " 148772 | \n",
1906 | "
\n",
1907 | " \n",
1908 | " 17 | \n",
1909 | " Almere | \n",
1910 | " NLD | \n",
1911 | " Flevoland | \n",
1912 | " 142465 | \n",
1913 | "
\n",
1914 | " \n",
1915 | " 18 | \n",
1916 | " Arnhem | \n",
1917 | " NLD | \n",
1918 | " Gelderland | \n",
1919 | " 138020 | \n",
1920 | "
\n",
1921 | " \n",
1922 | " 19 | \n",
1923 | " Zaanstad | \n",
1924 | " NLD | \n",
1925 | " Noord-Holland | \n",
1926 | " 135621 | \n",
1927 | "
\n",
1928 | " \n",
1929 | " 20 | \n",
1930 | " ´s-Hertogenbosch | \n",
1931 | " NLD | \n",
1932 | " Noord-Brabant | \n",
1933 | " 129170 | \n",
1934 | "
\n",
1935 | "
"
1936 | ],
1937 | "text/plain": [
1938 | "[(1, 'Kabul', 'AFG', 'Kabol', 1780000),\n",
1939 | " (2, 'Qandahar', 'AFG', 'Qandahar', 237500),\n",
1940 | " (3, 'Herat', 'AFG', 'Herat', 186800),\n",
1941 | " (4, 'Mazar-e-Sharif', 'AFG', 'Balkh', 127800),\n",
1942 | " (5, 'Amsterdam', 'NLD', 'Noord-Holland', 731200),\n",
1943 | " (6, 'Rotterdam', 'NLD', 'Zuid-Holland', 593321),\n",
1944 | " (7, 'Haag', 'NLD', 'Zuid-Holland', 440900),\n",
1945 | " (8, 'Utrecht', 'NLD', 'Utrecht', 234323),\n",
1946 | " (9, 'Eindhoven', 'NLD', 'Noord-Brabant', 201843),\n",
1947 | " (10, 'Tilburg', 'NLD', 'Noord-Brabant', 193238),\n",
1948 | " (11, 'Groningen', 'NLD', 'Groningen', 172701),\n",
1949 | " (12, 'Breda', 'NLD', 'Noord-Brabant', 160398),\n",
1950 | " (13, 'Apeldoorn', 'NLD', 'Gelderland', 153491),\n",
1951 | " (14, 'Nijmegen', 'NLD', 'Gelderland', 152463),\n",
1952 | " (15, 'Enschede', 'NLD', 'Overijssel', 149544),\n",
1953 | " (16, 'Haarlem', 'NLD', 'Noord-Holland', 148772),\n",
1954 | " (17, 'Almere', 'NLD', 'Flevoland', 142465),\n",
1955 | " (18, 'Arnhem', 'NLD', 'Gelderland', 138020),\n",
1956 | " (19, 'Zaanstad', 'NLD', 'Noord-Holland', 135621),\n",
1957 | " (20, '´s-Hertogenbosch', 'NLD', 'Noord-Brabant', 129170)]"
1958 | ]
1959 | },
1960 | "execution_count": 27,
1961 | "metadata": {},
1962 | "output_type": "execute_result"
1963 | }
1964 | ],
1965 | "source": [
1966 | "%%sql\n",
1967 | "SELECT * FROM city LIMIT 0,20"
1968 | ]
1969 | },
1970 | {
1971 | "cell_type": "markdown",
1972 | "metadata": {},
1973 | "source": [
1974 | "### Connect to PostgreSQL Database using sqlalchemy"
1975 | ]
1976 | },
1977 | {
1978 | "cell_type": "markdown",
1979 | "metadata": {},
1980 | "source": [
1981 | "#### PgAdmin Console"
1982 | ]
1983 | },
1984 | {
1985 | "cell_type": "markdown",
1986 | "metadata": {},
1987 | "source": [
1988 | "
"
1989 | ]
1990 | },
1991 | {
1992 | "cell_type": "code",
1993 | "execution_count": 29,
1994 | "metadata": {},
1995 | "outputs": [],
1996 | "source": [
1997 | "engine_postgresql = sqlalchemy.create_engine('postgresql://postgres:postgres@localhost:5432/Pagila')"
1998 | ]
1999 | },
2000 | {
2001 | "cell_type": "code",
2002 | "execution_count": 30,
2003 | "metadata": {},
2004 | "outputs": [
2005 | {
2006 | "name": "stdout",
2007 | "output_type": "stream",
2008 | "text": [
2009 | "connecting with engine Engine(postgresql://postgres:***@localhost:5432/Pagila)\n"
2010 | ]
2011 | }
2012 | ],
2013 | "source": [
2014 | "print(\"connecting with engine \" + str(engine_postgresql))"
2015 | ]
2016 | },
2017 | {
2018 | "cell_type": "code",
2019 | "execution_count": 31,
2020 | "metadata": {},
2021 | "outputs": [
2022 | {
2023 | "name": "stdout",
2024 | "output_type": "stream",
2025 | "text": [
2026 | "['actor', 'film', 'payment_p2007_02', 'payment_p2007_03', 'payment_p2007_04', 'payment_p2007_05', 'payment_p2007_06', 'payment_p2007_01', 'address', 'category', 'city', 'country', 'customer', 'film_actor', 'film_category', 'inventory', 'language', 'rental', 'staff', 'store', 'payment']\n"
2027 | ]
2028 | }
2029 | ],
2030 | "source": [
2031 | "print(engine_postgresql.table_names())"
2032 | ]
2033 | },
2034 | {
2035 | "cell_type": "code",
2036 | "execution_count": 32,
2037 | "metadata": {},
2038 | "outputs": [],
2039 | "source": [
2040 | "con_postgresql = engine_postgresql.connect()"
2041 | ]
2042 | },
2043 | {
2044 | "cell_type": "code",
2045 | "execution_count": 33,
2046 | "metadata": {},
2047 | "outputs": [
2048 | {
2049 | "data": {
2050 | "text/html": [
2051 | "\n",
2052 | "\n",
2065 | "
\n",
2066 | " \n",
2067 | " \n",
2068 | " | \n",
2069 | " category_id | \n",
2070 | " name | \n",
2071 | " last_update | \n",
2072 | "
\n",
2073 | " \n",
2074 | " \n",
2075 | " \n",
2076 | " 0 | \n",
2077 | " 1 | \n",
2078 | " Action | \n",
2079 | " 2006-02-15 09:46:27 | \n",
2080 | "
\n",
2081 | " \n",
2082 | " 1 | \n",
2083 | " 2 | \n",
2084 | " Animation | \n",
2085 | " 2006-02-15 09:46:27 | \n",
2086 | "
\n",
2087 | " \n",
2088 | " 2 | \n",
2089 | " 3 | \n",
2090 | " Children | \n",
2091 | " 2006-02-15 09:46:27 | \n",
2092 | "
\n",
2093 | " \n",
2094 | " 3 | \n",
2095 | " 4 | \n",
2096 | " Classics | \n",
2097 | " 2006-02-15 09:46:27 | \n",
2098 | "
\n",
2099 | " \n",
2100 | " 4 | \n",
2101 | " 5 | \n",
2102 | " Comedy | \n",
2103 | " 2006-02-15 09:46:27 | \n",
2104 | "
\n",
2105 | " \n",
2106 | " 5 | \n",
2107 | " 6 | \n",
2108 | " Documentary | \n",
2109 | " 2006-02-15 09:46:27 | \n",
2110 | "
\n",
2111 | " \n",
2112 | " 6 | \n",
2113 | " 7 | \n",
2114 | " Drama | \n",
2115 | " 2006-02-15 09:46:27 | \n",
2116 | "
\n",
2117 | " \n",
2118 | " 7 | \n",
2119 | " 8 | \n",
2120 | " Family | \n",
2121 | " 2006-02-15 09:46:27 | \n",
2122 | "
\n",
2123 | " \n",
2124 | " 8 | \n",
2125 | " 9 | \n",
2126 | " Foreign | \n",
2127 | " 2006-02-15 09:46:27 | \n",
2128 | "
\n",
2129 | " \n",
2130 | " 9 | \n",
2131 | " 10 | \n",
2132 | " Games | \n",
2133 | " 2006-02-15 09:46:27 | \n",
2134 | "
\n",
2135 | " \n",
2136 | " 10 | \n",
2137 | " 11 | \n",
2138 | " Horror | \n",
2139 | " 2006-02-15 09:46:27 | \n",
2140 | "
\n",
2141 | " \n",
2142 | " 11 | \n",
2143 | " 12 | \n",
2144 | " Music | \n",
2145 | " 2006-02-15 09:46:27 | \n",
2146 | "
\n",
2147 | " \n",
2148 | " 12 | \n",
2149 | " 13 | \n",
2150 | " New | \n",
2151 | " 2006-02-15 09:46:27 | \n",
2152 | "
\n",
2153 | " \n",
2154 | " 13 | \n",
2155 | " 14 | \n",
2156 | " Sci-Fi | \n",
2157 | " 2006-02-15 09:46:27 | \n",
2158 | "
\n",
2159 | " \n",
2160 | " 14 | \n",
2161 | " 15 | \n",
2162 | " Sports | \n",
2163 | " 2006-02-15 09:46:27 | \n",
2164 | "
\n",
2165 | " \n",
2166 | " 15 | \n",
2167 | " 16 | \n",
2168 | " Travel | \n",
2169 | " 2006-02-15 09:46:27 | \n",
2170 | "
\n",
2171 | " \n",
2172 | "
\n",
2173 | "
"
2174 | ],
2175 | "text/plain": [
2176 | " category_id name last_update\n",
2177 | "0 1 Action 2006-02-15 09:46:27\n",
2178 | "1 2 Animation 2006-02-15 09:46:27\n",
2179 | "2 3 Children 2006-02-15 09:46:27\n",
2180 | "3 4 Classics 2006-02-15 09:46:27\n",
2181 | "4 5 Comedy 2006-02-15 09:46:27\n",
2182 | "5 6 Documentary 2006-02-15 09:46:27\n",
2183 | "6 7 Drama 2006-02-15 09:46:27\n",
2184 | "7 8 Family 2006-02-15 09:46:27\n",
2185 | "8 9 Foreign 2006-02-15 09:46:27\n",
2186 | "9 10 Games 2006-02-15 09:46:27\n",
2187 | "10 11 Horror 2006-02-15 09:46:27\n",
2188 | "11 12 Music 2006-02-15 09:46:27\n",
2189 | "12 13 New 2006-02-15 09:46:27\n",
2190 | "13 14 Sci-Fi 2006-02-15 09:46:27\n",
2191 | "14 15 Sports 2006-02-15 09:46:27\n",
2192 | "15 16 Travel 2006-02-15 09:46:27"
2193 | ]
2194 | },
2195 | "execution_count": 33,
2196 | "metadata": {},
2197 | "output_type": "execute_result"
2198 | }
2199 | ],
2200 | "source": [
2201 | "query = \"select * from category\"\n",
2202 | "df_postgresql = pd.read_sql_query(query, con_postgresql)\n",
2203 | "df_postgresql"
2204 | ]
2205 | },
2206 | {
2207 | "cell_type": "markdown",
2208 | "metadata": {},
2209 | "source": [
2210 | "### Connect to PostgreSQL Using psycopg2"
2211 | ]
2212 | },
2213 | {
2214 | "cell_type": "markdown",
2215 | "metadata": {},
2216 | "source": [
2217 | "#### pgAdmin Console"
2218 | ]
2219 | },
2220 | {
2221 | "cell_type": "markdown",
2222 | "metadata": {},
2223 | "source": [
2224 | "
"
2225 | ]
2226 | },
2227 | {
2228 | "cell_type": "code",
2229 | "execution_count": 39,
2230 | "metadata": {},
2231 | "outputs": [],
2232 | "source": [
2233 | "engine_postgresql1 = sqlalchemy.create_engine('postgresql+psycopg2://postgres:postgres@localhost:5432/NorthWind')"
2234 | ]
2235 | },
2236 | {
2237 | "cell_type": "code",
2238 | "execution_count": 40,
2239 | "metadata": {},
2240 | "outputs": [
2241 | {
2242 | "name": "stdout",
2243 | "output_type": "stream",
2244 | "text": [
2245 | "connecting with engine Engine(postgresql+psycopg2://postgres:***@localhost:5432/NorthWind)\n"
2246 | ]
2247 | }
2248 | ],
2249 | "source": [
2250 | "print(\"connecting with engine \" + str(engine_postgresql1))"
2251 | ]
2252 | },
2253 | {
2254 | "cell_type": "code",
2255 | "execution_count": 41,
2256 | "metadata": {},
2257 | "outputs": [
2258 | {
2259 | "name": "stdout",
2260 | "output_type": "stream",
2261 | "text": [
2262 | "['us_states', 'customers', 'orders', 'employees', 'shippers', 'products', 'order_details', 'categories', 'suppliers', 'region', 'territories', 'employee_territories', 'customer_demographics', 'customer_customer_demo']\n"
2263 | ]
2264 | }
2265 | ],
2266 | "source": [
2267 | "print(engine_postgresql1.table_names())"
2268 | ]
2269 | },
2270 | {
2271 | "cell_type": "code",
2272 | "execution_count": 42,
2273 | "metadata": {},
2274 | "outputs": [],
2275 | "source": [
2276 | "con_postgresql1 = engine_postgresql1.connect()"
2277 | ]
2278 | },
2279 | {
2280 | "cell_type": "code",
2281 | "execution_count": 45,
2282 | "metadata": {},
2283 | "outputs": [
2284 | {
2285 | "data": {
2286 | "text/html": [
2287 | "\n",
2288 | "\n",
2301 | "
\n",
2302 | " \n",
2303 | " \n",
2304 | " | \n",
2305 | " category_id | \n",
2306 | " category_name | \n",
2307 | " description | \n",
2308 | " picture | \n",
2309 | "
\n",
2310 | " \n",
2311 | " \n",
2312 | " \n",
2313 | " 0 | \n",
2314 | " 1 | \n",
2315 | " Beverages | \n",
2316 | " Soft drinks, coffees, teas, beers, and ales | \n",
2317 | " [] | \n",
2318 | "
\n",
2319 | " \n",
2320 | " 1 | \n",
2321 | " 2 | \n",
2322 | " Condiments | \n",
2323 | " Sweet and savory sauces, relishes, spreads, an... | \n",
2324 | " [] | \n",
2325 | "
\n",
2326 | " \n",
2327 | " 2 | \n",
2328 | " 3 | \n",
2329 | " Confections | \n",
2330 | " Desserts, candies, and sweet breads | \n",
2331 | " [] | \n",
2332 | "
\n",
2333 | " \n",
2334 | " 3 | \n",
2335 | " 4 | \n",
2336 | " Dairy Products | \n",
2337 | " Cheeses | \n",
2338 | " [] | \n",
2339 | "
\n",
2340 | " \n",
2341 | " 4 | \n",
2342 | " 5 | \n",
2343 | " Grains/Cereals | \n",
2344 | " Breads, crackers, pasta, and cereal | \n",
2345 | " [] | \n",
2346 | "
\n",
2347 | " \n",
2348 | " 5 | \n",
2349 | " 6 | \n",
2350 | " Meat/Poultry | \n",
2351 | " Prepared meats | \n",
2352 | " [] | \n",
2353 | "
\n",
2354 | " \n",
2355 | " 6 | \n",
2356 | " 7 | \n",
2357 | " Produce | \n",
2358 | " Dried fruit and bean curd | \n",
2359 | " [] | \n",
2360 | "
\n",
2361 | " \n",
2362 | " 7 | \n",
2363 | " 8 | \n",
2364 | " Seafood | \n",
2365 | " Seaweed and fish | \n",
2366 | " [] | \n",
2367 | "
\n",
2368 | " \n",
2369 | "
\n",
2370 | "
"
2371 | ],
2372 | "text/plain": [
2373 | " category_id category_name \\\n",
2374 | "0 1 Beverages \n",
2375 | "1 2 Condiments \n",
2376 | "2 3 Confections \n",
2377 | "3 4 Dairy Products \n",
2378 | "4 5 Grains/Cereals \n",
2379 | "5 6 Meat/Poultry \n",
2380 | "6 7 Produce \n",
2381 | "7 8 Seafood \n",
2382 | "\n",
2383 | " description picture \n",
2384 | "0 Soft drinks, coffees, teas, beers, and ales [] \n",
2385 | "1 Sweet and savory sauces, relishes, spreads, an... [] \n",
2386 | "2 Desserts, candies, and sweet breads [] \n",
2387 | "3 Cheeses [] \n",
2388 | "4 Breads, crackers, pasta, and cereal [] \n",
2389 | "5 Prepared meats [] \n",
2390 | "6 Dried fruit and bean curd [] \n",
2391 | "7 Seaweed and fish [] "
2392 | ]
2393 | },
2394 | "execution_count": 45,
2395 | "metadata": {},
2396 | "output_type": "execute_result"
2397 | }
2398 | ],
2399 | "source": [
2400 | "query = \"select * from categories\"\n",
2401 | "df_postgresql1 = pd.read_sql_query(query, con_postgresql1)\n",
2402 | "df_postgresql1"
2403 | ]
2404 | },
2405 | {
2406 | "cell_type": "markdown",
2407 | "metadata": {},
2408 | "source": [
2409 | "### Connect to PostgreSQL Database using ipython-sql"
2410 | ]
2411 | },
2412 | {
2413 | "cell_type": "code",
2414 | "execution_count": 48,
2415 | "metadata": {},
2416 | "outputs": [
2417 | {
2418 | "name": "stdout",
2419 | "output_type": "stream",
2420 | "text": [
2421 | "The sql extension is already loaded. To reload it, use:\n",
2422 | " %reload_ext sql\n"
2423 | ]
2424 | }
2425 | ],
2426 | "source": [
2427 | "%load_ext sql\n",
2428 | "%sql \"postgresql://postgres:postgres@localhost:5432/Pagila\""
2429 | ]
2430 | },
2431 | {
2432 | "cell_type": "code",
2433 | "execution_count": 49,
2434 | "metadata": {},
2435 | "outputs": [
2436 | {
2437 | "name": "stdout",
2438 | "output_type": "stream",
2439 | "text": [
2440 | " mssql+pyodbc://abhat:***@sqldb1\n",
2441 | " mssql+pyodbc://dstran:***@sqldb\n",
2442 | " mysql+pymysql://root:***@localhost:3306/world\n",
2443 | " oracle://c##abhat:***@localhost:1521/orcl\n",
2444 | " * postgresql://postgres:***@localhost:5432/Pagila\n",
2445 | "16 rows affected.\n"
2446 | ]
2447 | },
2448 | {
2449 | "data": {
2450 | "text/html": [
2451 | "\n",
2452 | " \n",
2453 | " category_id | \n",
2454 | " name | \n",
2455 | " last_update | \n",
2456 | "
\n",
2457 | " \n",
2458 | " 1 | \n",
2459 | " Action | \n",
2460 | " 2006-02-15 09:46:27 | \n",
2461 | "
\n",
2462 | " \n",
2463 | " 2 | \n",
2464 | " Animation | \n",
2465 | " 2006-02-15 09:46:27 | \n",
2466 | "
\n",
2467 | " \n",
2468 | " 3 | \n",
2469 | " Children | \n",
2470 | " 2006-02-15 09:46:27 | \n",
2471 | "
\n",
2472 | " \n",
2473 | " 4 | \n",
2474 | " Classics | \n",
2475 | " 2006-02-15 09:46:27 | \n",
2476 | "
\n",
2477 | " \n",
2478 | " 5 | \n",
2479 | " Comedy | \n",
2480 | " 2006-02-15 09:46:27 | \n",
2481 | "
\n",
2482 | " \n",
2483 | " 6 | \n",
2484 | " Documentary | \n",
2485 | " 2006-02-15 09:46:27 | \n",
2486 | "
\n",
2487 | " \n",
2488 | " 7 | \n",
2489 | " Drama | \n",
2490 | " 2006-02-15 09:46:27 | \n",
2491 | "
\n",
2492 | " \n",
2493 | " 8 | \n",
2494 | " Family | \n",
2495 | " 2006-02-15 09:46:27 | \n",
2496 | "
\n",
2497 | " \n",
2498 | " 9 | \n",
2499 | " Foreign | \n",
2500 | " 2006-02-15 09:46:27 | \n",
2501 | "
\n",
2502 | " \n",
2503 | " 10 | \n",
2504 | " Games | \n",
2505 | " 2006-02-15 09:46:27 | \n",
2506 | "
\n",
2507 | " \n",
2508 | " 11 | \n",
2509 | " Horror | \n",
2510 | " 2006-02-15 09:46:27 | \n",
2511 | "
\n",
2512 | " \n",
2513 | " 12 | \n",
2514 | " Music | \n",
2515 | " 2006-02-15 09:46:27 | \n",
2516 | "
\n",
2517 | " \n",
2518 | " 13 | \n",
2519 | " New | \n",
2520 | " 2006-02-15 09:46:27 | \n",
2521 | "
\n",
2522 | " \n",
2523 | " 14 | \n",
2524 | " Sci-Fi | \n",
2525 | " 2006-02-15 09:46:27 | \n",
2526 | "
\n",
2527 | " \n",
2528 | " 15 | \n",
2529 | " Sports | \n",
2530 | " 2006-02-15 09:46:27 | \n",
2531 | "
\n",
2532 | " \n",
2533 | " 16 | \n",
2534 | " Travel | \n",
2535 | " 2006-02-15 09:46:27 | \n",
2536 | "
\n",
2537 | "
"
2538 | ],
2539 | "text/plain": [
2540 | "[(1, 'Action', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2541 | " (2, 'Animation', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2542 | " (3, 'Children', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2543 | " (4, 'Classics', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2544 | " (5, 'Comedy', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2545 | " (6, 'Documentary', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2546 | " (7, 'Drama', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2547 | " (8, 'Family', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2548 | " (9, 'Foreign', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2549 | " (10, 'Games', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2550 | " (11, 'Horror', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2551 | " (12, 'Music', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2552 | " (13, 'New', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2553 | " (14, 'Sci-Fi', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2554 | " (15, 'Sports', datetime.datetime(2006, 2, 15, 9, 46, 27)),\n",
2555 | " (16, 'Travel', datetime.datetime(2006, 2, 15, 9, 46, 27))]"
2556 | ]
2557 | },
2558 | "execution_count": 49,
2559 | "metadata": {},
2560 | "output_type": "execute_result"
2561 | }
2562 | ],
2563 | "source": [
2564 | "%%sql\n",
2565 | "SELECT * FROM category"
2566 | ]
2567 | },
2568 | {
2569 | "cell_type": "code",
2570 | "execution_count": 50,
2571 | "metadata": {},
2572 | "outputs": [
2573 | {
2574 | "name": "stdout",
2575 | "output_type": "stream",
2576 | "text": [
2577 | "The sql extension is already loaded. To reload it, use:\n",
2578 | " %reload_ext sql\n"
2579 | ]
2580 | }
2581 | ],
2582 | "source": [
2583 | "%load_ext sql\n",
2584 | "%sql \"postgresql+psycopg2://postgres:postgres@localhost:5432/NorthWind\""
2585 | ]
2586 | },
2587 | {
2588 | "cell_type": "code",
2589 | "execution_count": 52,
2590 | "metadata": {},
2591 | "outputs": [
2592 | {
2593 | "name": "stdout",
2594 | "output_type": "stream",
2595 | "text": [
2596 | " mssql+pyodbc://abhat:***@sqldb1\n",
2597 | " mssql+pyodbc://dstran:***@sqldb\n",
2598 | " mysql+pymysql://root:***@localhost:3306/world\n",
2599 | " oracle://c##abhat:***@localhost:1521/orcl\n",
2600 | " * postgresql+psycopg2://postgres:***@localhost:5432/NorthWind\n",
2601 | " postgresql://postgres:***@localhost:5432/Pagila\n",
2602 | "8 rows affected.\n"
2603 | ]
2604 | },
2605 | {
2606 | "data": {
2607 | "text/html": [
2608 | "\n",
2609 | " \n",
2610 | " category_name | \n",
2611 | " description | \n",
2612 | "
\n",
2613 | " \n",
2614 | " Beverages | \n",
2615 | " Soft drinks, coffees, teas, beers, and ales | \n",
2616 | "
\n",
2617 | " \n",
2618 | " Condiments | \n",
2619 | " Sweet and savory sauces, relishes, spreads, and seasonings | \n",
2620 | "
\n",
2621 | " \n",
2622 | " Confections | \n",
2623 | " Desserts, candies, and sweet breads | \n",
2624 | "
\n",
2625 | " \n",
2626 | " Dairy Products | \n",
2627 | " Cheeses | \n",
2628 | "
\n",
2629 | " \n",
2630 | " Grains/Cereals | \n",
2631 | " Breads, crackers, pasta, and cereal | \n",
2632 | "
\n",
2633 | " \n",
2634 | " Meat/Poultry | \n",
2635 | " Prepared meats | \n",
2636 | "
\n",
2637 | " \n",
2638 | " Produce | \n",
2639 | " Dried fruit and bean curd | \n",
2640 | "
\n",
2641 | " \n",
2642 | " Seafood | \n",
2643 | " Seaweed and fish | \n",
2644 | "
\n",
2645 | "
"
2646 | ],
2647 | "text/plain": [
2648 | "[('Beverages', 'Soft drinks, coffees, teas, beers, and ales'),\n",
2649 | " ('Condiments', 'Sweet and savory sauces, relishes, spreads, and seasonings'),\n",
2650 | " ('Confections', 'Desserts, candies, and sweet breads'),\n",
2651 | " ('Dairy Products', 'Cheeses'),\n",
2652 | " ('Grains/Cereals', 'Breads, crackers, pasta, and cereal'),\n",
2653 | " ('Meat/Poultry', 'Prepared meats'),\n",
2654 | " ('Produce', 'Dried fruit and bean curd'),\n",
2655 | " ('Seafood', 'Seaweed and fish')]"
2656 | ]
2657 | },
2658 | "execution_count": 52,
2659 | "metadata": {},
2660 | "output_type": "execute_result"
2661 | }
2662 | ],
2663 | "source": [
2664 | "%%sql\n",
2665 | "SELECT category_name , description FROM categories"
2666 | ]
2667 | },
2668 | {
2669 | "cell_type": "markdown",
2670 | "metadata": {},
2671 | "source": [
2672 | "# END"
2673 | ]
2674 | }
2675 | ],
2676 | "metadata": {
2677 | "kernelspec": {
2678 | "display_name": "Python 3 (ipykernel)",
2679 | "language": "python",
2680 | "name": "python3"
2681 | },
2682 | "language_info": {
2683 | "codemirror_mode": {
2684 | "name": "ipython",
2685 | "version": 3
2686 | },
2687 | "file_extension": ".py",
2688 | "mimetype": "text/x-python",
2689 | "name": "python",
2690 | "nbconvert_exporter": "python",
2691 | "pygments_lexer": "ipython3",
2692 | "version": "3.9.12"
2693 | },
2694 | "varInspector": {
2695 | "cols": {
2696 | "lenName": 16,
2697 | "lenType": 16,
2698 | "lenVar": 40
2699 | },
2700 | "kernels_config": {
2701 | "python": {
2702 | "delete_cmd_postfix": "",
2703 | "delete_cmd_prefix": "del ",
2704 | "library": "var_list.py",
2705 | "varRefreshCmd": "print(var_dic_list())"
2706 | },
2707 | "r": {
2708 | "delete_cmd_postfix": ") ",
2709 | "delete_cmd_prefix": "rm(",
2710 | "library": "var_list.r",
2711 | "varRefreshCmd": "cat(var_dic_list()) "
2712 | }
2713 | },
2714 | "types_to_exclude": [
2715 | "module",
2716 | "function",
2717 | "builtin_function_or_method",
2718 | "instance",
2719 | "_Feature"
2720 | ],
2721 | "window_display": false
2722 | }
2723 | },
2724 | "nbformat": 4,
2725 | "nbformat_minor": 4
2726 | }
2727 |
--------------------------------------------------------------------------------
/PyMySQL.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/PyMySQL.PNG
--------------------------------------------------------------------------------
/SQLAlchemy.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/SQLAlchemy.PNG
--------------------------------------------------------------------------------
/cx_oracle.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/cx_oracle.PNG
--------------------------------------------------------------------------------
/ipython-sql.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/ipython-sql.PNG
--------------------------------------------------------------------------------
/ipython-sql1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/ipython-sql1.PNG
--------------------------------------------------------------------------------
/jupyter-sql.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/jupyter-sql.PNG
--------------------------------------------------------------------------------
/mysql1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/mysql1.PNG
--------------------------------------------------------------------------------
/mysql2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/mysql2.PNG
--------------------------------------------------------------------------------
/odbc0.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc0.PNG
--------------------------------------------------------------------------------
/odbc1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc1.PNG
--------------------------------------------------------------------------------
/odbc2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc2.PNG
--------------------------------------------------------------------------------
/odbc3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc3.PNG
--------------------------------------------------------------------------------
/odbc4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc4.PNG
--------------------------------------------------------------------------------
/odbc5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc5.PNG
--------------------------------------------------------------------------------
/odbc6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/odbc6.PNG
--------------------------------------------------------------------------------
/ora_con.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/ora_con.PNG
--------------------------------------------------------------------------------
/oracle1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/oracle1.PNG
--------------------------------------------------------------------------------
/oracle2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/oracle2.PNG
--------------------------------------------------------------------------------
/oracle3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/oracle3.PNG
--------------------------------------------------------------------------------
/oracle4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/oracle4.PNG
--------------------------------------------------------------------------------
/oracle5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/oracle5.PNG
--------------------------------------------------------------------------------
/pgAdmin.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/pgAdmin.PNG
--------------------------------------------------------------------------------
/pgAdmin1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/pgAdmin1.PNG
--------------------------------------------------------------------------------
/psycopg2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/psycopg2.PNG
--------------------------------------------------------------------------------
/pyodbc.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/pyodbc.PNG
--------------------------------------------------------------------------------
/sqldb1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datasciencescoop/SQL/f926847ff05f34a47323eedef3b1db70e1f138fc/sqldb1.PNG
--------------------------------------------------------------------------------