Question: Please fill in the following Python code below, with the answers in correlation with the database and Questions in the provided images Python Code: import

Please fill in the following Python code below, with the answers in correlation with the database and Questions in the provided images
Python Code:
import sqlite3
from sqlite3 import Error
def openConnection(_dbFile):
print("++++++++++++++++++++++++++++++++++")
print("Open database: ",_dbFile)
conn = None
try:
conn = sqlite3.connect(_dbFile)
print("success")
except Error as e:
print(e)
print("++++++++++++++++++++++++++++++++++")
return conn
def closeConnection(_conn, _dbFile):
print("++++++++++++++++++++++++++++++++++")
print("Close database: ",_dbFile)
try:
_conn.close()
print("success")
except Error as e:
print(e)
print("++++++++++++++++++++++++++++++++++")
def createTable(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Create table")
print("++++++++++++++++++++++++++++++++++")
def dropTable(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Drop tables")
print("++++++++++++++++++++++++++++++++++")
def populateTable(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Populate table")
print("++++++++++++++++++++++++++++++++++")
def Q1(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Q1")
try:
output = open('output/1.out', 'w')
sql =_conn.execute("SELECT * FROM warehouse")
table = sql.fetchall()
header ="{:>10}{:<40}{:>10}{:>10}{:>10}"
output.write((header.format("wId", "wName", "wCap", "sId", "nId"))+'
')
for i in range(0, len(table)):
output.write((header.format(str(table[i][0]), str(table[i][1]), str(table[i][2]), str(table[i][3]), str(table[i][4])))+'
')
output.close()
except Error as e:
print(e)
print("++++++++++++++++++++++++++++++++++")
def Q2(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Q2")
try:
output = open('output/2.out', 'w')
header ="{:<40}{:>10}{:>10}"
output.write((header.format("nation", "numW", "totCap"))+'
')
output.close()
except Error as e:
print(e)
print("++++++++++++++++++++++++++++++++++")
def Q3(_conn):
print("++++++++++++++++++++++++++++++++++")
print("Q3")
try:
input = open("input/3.in","r")
nation = input.readline().strip()
input.close()
output = open('output/3.out', 'w')
header ="{:<20}{:<20}{:<40}"
output.write((header.format("supplier", "nation", "warehouse"))+'
')

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 Programming Questions!