0

I want to insert a row into my table, but I am getting an error. Where am I going wrong?

CREATE TABLE  person (

  name          VARCHAR(40),
  birthday      DATE,
  PRIMARY KEY (name)
  );

Now in python I try to insert a person with the following statement...

     curs = connection.cursor

     name = input("Name: ")
     birthday = input("Birthdate(yyyy-mm-dd): ")

     insert = """insert into people(name, birthday) values (:name,:birthday)"""

     curs.execute(insert,{'name':name,'to_date(birthday, "yyyy-mm-dd")':birthday})

I get the following error:

curs.execute(insert,{'name':name,'to_date(birthday, "yyyy-mm-dd")':birthday})
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number

1 Answer 1

2

Figured it out, I was inserting the date wrong. My syntax was incorrect and should have been:

 curs = connection.cursor

 name = input("Name: ")
 birthday = input("Birthdate(yyyy-mm-dd): ")

 insert = """insert into people(name, birthday) values (:name, to_date(:birthday, 'yyyy-mm-dd'))"""

 curs.execute(insert,{'name':name, 'birthday':birthday})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.