Pycharm中的代码:
import MySQLdb
db = MySQLdb.connect("127.0.0.1", "xxx", "xxx", "xxxxxxx")
cursor = db.cursor()
sql="""CREATE TABLE EMPLOYEE (
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INI,
SEX CHAR(1),
INCOME FLOAT )"""
cursor.execute(sql)
db.close()
问题:
/usr/bin/python2.7 /home/mfae/PycharmProjects/dbs/create.py
/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning: /home/mfae/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
Traceback (most recent call last):
File "/home/mfae/PycharmProjects/dbs/create.py", line 14, in <module>
cursor.execute(sql)
File "build/bdist.linux-i686/egg/MySQLdb/cursors.py", line 205, in execute
File "build/bdist.linux-i686/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
_mysql_exceptions.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 'INI,\n SEX CHAR(1),\n INCOME FLOAT )' at line 4")
Process finished with exit code 1
流程以退出代码1结束 进程以退出代码1结束 处理以退出代码1完成
解决方案是什么?
答案 0 :(得分:0)
就像错误所说,你应该
将AGE INI
更改为AGE INT
。