Mysql and Python, Insert Rows into a Table

The Horse table has the following columns:

  • ID - integer, auto increment, primary key
  • RegisteredName - variable-length string
  • Breed - variable-length string, must be one of the following: Egyptian Arab, Holsteiner, Quarter Horse, Paint, Saddlebred
  • Height - decimal number, must be between 10.0 and 20.0
  • BirthDate - date, must be on or after Jan 1, 2015

Insert the following data into the Horse table:

RegisteredName  Breed           Height  BirthDate
Babe            Quarter Horse   15.3    2015-02-10
Independence    Holsteiner      16.0    2017-03-13
Ellie           Saddlebred      15.0    2016-12-22
NULL            Egyptian Arab   14.9    2019-10-12

Table exists and does not need to be built.

CODE UPDATE;

INSERT [INTO] Horse (RegisteredName, Breed, Height, BirthDate)
VALUES ('Babe', 'Quarter Horse', '15.3', '2015-02-10')

INSERT INTO Horse (RegisteredName, Breed, Height, BirthDate)
VALUES ('Independence', 'Holsteiner', 16.0, '2017-03-13')

INSERT INTO Horse (RegisteredName, Breed, Height, BirthDate)
VALUES ('Ellie', 'Saddlebred', 15.0, '2016-12-22')

INSERT INTO Horse (Breed, Height, BirthDate)
VALUES ('Egyptian Arab', 14.9, '2019-10-12');

Now errors lie in line 4. What am I missing?

0

1 Answer

I believe you first have to create the table with:

CREATE TABLE Horse(RegisteredName, Breed, Height, BirthDate)

Then:

INSERT INTO Horse 
VALUES ('Babe', 'QuarterHorse', '15.3', '2015-02-10')

I could be wrong but it worked for me.

*Are you using SQL or Python?

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest