Question: 9 . 8 LAB - Database programming with Python LAB 9 . 8 . 1 : LAB - Database programming with Python Complete the Python

9.8 LAB - Database programming with Python
LAB
9.8.1: LAB - Database programming with Python
Complete the Python program to create a Horse table, insert one row, and print the row.
Implement the following functions. Function parameters are described in the template. Do not modify the main program. create_connection() creates a connection to the database. This function calls mysql. connector. connect () with three arguments:
- user='root'
- host='127.0.0.1'
- database='zybooksdb'
The password argument is not necessary and can be omitted.
create_table () creates Horse, with five columns:
- ID - integer, primary key
- Name - varchar(30)
- Breed - varchar(30)
- Height-double
- BirthDate - varchar(10)
Before creating Horse, drop the table if the table exists (from a prior run).
insert_horse () inserts one row into Horse:
(1, 'Babe', 'Quarter horse', 15.3,'2015-02-10')
select_all_horses () selects and prints all Horse rows, as follows:
All horses:
(1, 'Babe', 'Quarter Horse', 15.3,'2015-02-10')
Latest submission -5:06 PM EST on 11/10/24
Only show failing tests
Open submission's code
1: Unit test all functions
\(0/9\)
Test create_connection(), create_table(), and insert_row() functions
Test create_connection(), create_table(), and insert_row() functions
```
b/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line-883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/usercode/coding_rooms_unit_tests.py", line 4; in
import main
File "/usercode/main.py", line 10, in
c.execute('''
sqlite3.OperationalError: table stocks already exists
```
2: Compare output
Compare program output to expected output
```
Traceback (most recent call last):
File "/usercode/main.py", line 10, in
c.execute(",\
sqlite3.OperationalError: table stocks already exists
```
9 . 8 LAB - Database programming with Python LAB

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!