Create and commit records
This commit is contained in:
parent
828cb51141
commit
63fa8e39b8
|
@ -24,8 +24,15 @@ def main():
|
||||||
course_instructor VARCHAR (100) NOT NULL,
|
course_instructor VARCHAR (100) NOT NULL,
|
||||||
topic VARCHAR (20) 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("Committing the table to the database...")
|
||||||
print("Closing the connection adn the cursor...")
|
conn.commit()
|
||||||
|
print("Closing the connection and the cursor...")
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
# cursor.execute("SELECT * FROM DB_table WHERE id = 1")
|
# cursor.execute("SELECT * FROM DB_table WHERE id = 1")
|
||||||
|
|
Loading…
Reference in New Issue