Creates a sqlite3 database connection def create_connection(db_file): create a database connection to a SQLite database
Question:
Creates a sqlite3 database connection
def create_connection(db_file):
""" create a database connection to a SQLite database """
conn = None try: conn = sqlite3.connect(":memory:")
return conn
except Error as e:
print(e) return conn
# Creates a table
def create_table(conn, create_table_sql):
# FIXME: Type your code here
# Inserts horse data as a row in the database
def insert_horse(conn, data):
# FIXME: Type your code here
# Prints all rows of data fromthe horses table
def select_all_horses(conn):
# FIXME: Type your code here
if __name__ == '__main__': database = r"HorseStable.db"
# FIXME 1: Call the create_connection function to connect to the database HorseStable.db
# FIXME 2: Create the sql statement string to create a table # FIXME 3: Call the create_table function passing the sql statement string
# FIXME 4: Insert the horse data into the database
# FIXME 5: Print out all hourses by calling the select_all_horses function
Modern Database Management
ISBN: 978-0133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi