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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!