I have an sql file containing, say,
INSERT INTO mytable (ID, Date) VALUES (1, datetime.date(2023, 2, 22));
How do I create a table that will accept this? More explicitly, in
CREATE TABLE mytable(ID INT NOT NULL, Date ???)) ENGINE=INNODB;
what should I put in place of '????'?
When I substitute varchar(12) for ????,
I get the error message:
mysql.connector.errors.ProgrammingError: 1630 (42000): FUNCTION datetime.date does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual.
Checking doesn't reveal any insights, at least for me. What should I be doing?
You can directly pass a date in string format (ex. '2023-02-22'), notice the quotes since it should be a string. Also, the data type of the column should simply be a DATE.
Create table:
CREATE TABLE mytable(ID INT NOT NULL, Date DATE) ENGINE=INNODB;Insert values:
INSERT INTO mytable (ID, Date) VALUES (1, '2023-02-22');