Create and commit records

This commit is contained in:
slashtechno 2024-06-04 10:46:42 -05:00
parent 828cb51141
commit 63fa8e39b8
Signed by: slashtechno
GPG Key ID: 8EC1D9D9286C2B17
1 changed files with 8 additions and 1 deletions

View File

@ -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")