我想在我的表中插入一行,但是我收到了一个错误。我哪里错了?
CREATE TABLE person (
name VARCHAR(40),
birthday DATE,
PRIMARY KEY (name)
);
现在在python中,我尝试使用以下语句插入一个人......
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})
我收到以下错误:
curs.execute(insert,{'name':name,'to_date(birthday, "yyyy-mm-dd")':birthday})
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
答案 0 :(得分:1)
想出来,我插错了日期。 我的语法不正确,应该是:
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})