0
der Code in PyCharm:PyCharm: MySQLdb und Datenbank
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()
das Problem:
/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
Prozess mit Beendigungscode beendet 1 Prozess mit Beendigungscode 1 Prozess beendet abgeschlossen mit Exitcode 1
Was ist die Lösung?
Ändern Sie den Datentyp von 'AGE' in' INT'. – Viki888
Alter INI? oder AGE INT? – FisherMartyn
danke die ganze lösung – mfae