Hanley Soilsmith Hanley Soilsmith - 1 year ago 90
MySQL Question

CREATE TABLE syntax error in mysql 6.3/python 3.5

I'm using python to create a table in a mysql 6.3. The code worked great when using sqlite and is now throwing the following error.

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '

REAL, primary key (rowid))' at line 1")

the code is

import pymysql
sql='''CREATE TABLE pressure (rowid INT AUTO_INCREMENT NOT NULL, date_time,
tokyo REAL, primary key (rowid));'''

Any help is greatly appreciated!

Answer Source

You need to specify the datatype for the date_time column, say DATETIME:

sql='''CREATE TABLE pressure (rowid INT AUTO_INCREMENT NOT NULL, date_time DATETIME, tokyo REAL, primary key (rowid));'''


Create Table syntax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download