From 63fa8e39b8163bf474c7151846248d71ac539382 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:46:42 -0500 Subject: [PATCH] Create and commit records --- src/hello_postgres/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hello_postgres/__main__.py b/src/hello_postgres/__main__.py index 1f3cfb7..225ed79 100644 --- a/src/hello_postgres/__main__.py +++ b/src/hello_postgres/__main__.py @@ -24,8 +24,15 @@ def main(): course_instructor VARCHAR (100) NOT NULL, topic VARCHAR (20) NOT NULL); """) + print("Creating some records...") + cursor.execute("INSERT INTO datacamp_courses(course_name, course_instructor, topic) VALUES('Introduction to SQL','Izzy Weber','Julia')"); + cursor.execute("INSERT INTO datacamp_courses(course_name, course_instructor, topic) VALUES('Analyzing Survey Data in Python','EbunOluwa Andrew','Python')"); + cursor.execute("INSERT INTO datacamp_courses(course_name, course_instructor, topic) VALUES('Introduction to ChatGPT','James Chapman','Theory')"); + cursor.execute("INSERT INTO datacamp_courses(course_name, course_instructor, topic) VALUES('Introduction to Statistics in R','Maggie Matsui','R')"); + cursor.execute("INSERT INTO datacamp_courses(course_name, course_instructor, topic) VALUES('Hypothesis Testing in Python','James Chapman','Python')"); print("Committing the table to the database...") - print("Closing the connection adn the cursor...") + conn.commit() + print("Closing the connection and the cursor...") cursor.close() conn.close() # cursor.execute("SELECT * FROM DB_table WHERE id = 1")