Load data from a list into the Table
Using the multiple insert pattern, in this exercise, you will load the data from values_list
into the table.
This exercise is part of the course
Introduction to Databases in Python
Exercise instructions
- Import
insert
fromsqlalchemy
. - Build an insert statement for the
census
table. - Execute the statement
stmt
along withvalues_list
. You will need to pass them both as arguments toconnection.execute()
. - Print the
rowcount
attribute ofresults
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import insert
# Build insert statement: stmt
# Use values_list to insert data: results
# Print rowcount
print(____)