Question
6.22 ZyBooks Lab Python import sqlite3 from sqlite3 import Error # NOTE: Do not modify # Creates a sqlite3 database connection (in memory) def create_connection(db_file):
6.22 ZyBooks Lab Python
import sqlite3
from sqlite3 import Error
# NOTE: Do not modify
# Creates a sqlite3 database connection (in memory)
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started