From ffc8d86e93db23489545295fc98793fd5dbe544a Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Sat, 21 Oct 2023 10:15:21 -0400 Subject: [PATCH] starting python sql --- python_sql/README.md | 47 ++++++++++++++++++++++++++++++++++++++++++ python_sql/overview.md | 15 -------------- 2 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 python_sql/README.md delete mode 100644 python_sql/overview.md diff --git a/python_sql/README.md b/python_sql/README.md new file mode 100644 index 0000000..64fe7a5 --- /dev/null +++ b/python_sql/README.md @@ -0,0 +1,47 @@ +# Plan for Python + SQL + +## Lessons + +1. Install a Python virtual environment +1. Install psychopg2-binary +1. Connect to Postgres via Python +1. Running Queries with Python +1. Migrating data to a SQLite +1. Exporting data to CSV +1. Create an API with Flask +1. Create a web UI to customize automation + +## Install a Python virtual environment + +``` +python3 -m venv ~/my-env +source ~/my-env/bin/activate +``` + +## Install psychopg2-binary + +``` +python -m pip install psycopg2-binary +``` + +## Connect to Postgres via Python + +```python +import psycopg2 +conn = psycopg2.connect( + database="supertest_lab" +) +``` + +## Running Queries with Python + +```python +cursor = conn.cursor() +cursor.execute("SELECT * FROM people") +print(cursor.fetchall()) +``` + +## Labs + +1. create a terminal based customer relationship management tool +1. migrate the CRM from previous lab to simple web app with an API diff --git a/python_sql/overview.md b/python_sql/overview.md deleted file mode 100644 index 7d2c85d..0000000 --- a/python_sql/overview.md +++ /dev/null @@ -1,15 +0,0 @@ -# Plan for Python + SQL - -## Lessons - -1. Connecting to Postgres via Python -1. Running Queries with Python -1. Migrating data to a SQLite -1. Exporting data to CSV -1. Create an API with Flask -1. Create a web UI to customize automation - -## Labs - -1. create a terminal based customer relationship management tool -1. migrate the CRM from previous lab to simple web app with an API