提问人:Dominic Barth 提问时间:11/18/2023 最后编辑:Bill KarwinDominic Barth 更新时间:11/18/2023 访问量:52
请帮忙,我正在尝试使用 python 创建一个表,我一直收到此错误 = [关闭]
Please help, I am trying to create a table using python, I keep getting this error = [closed]
问:
Traceback (most recent call last):
File "C:\Users\Donchaka\Desktop\ADVANCED PY\05 SQL\Creating a Table.py", line 62, in <module>
cursor.execute ("CREATE TABLE People (Name varchar(50), Age int, City varchar(50)" )
File "C:\Users\Donchaka\AppData\Roaming\Python\Python37\site-packages\mysql\connector\cursor.py", line 551, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "C:\Users\Donchaka\AppData\Roaming\Python\Python37\site-packages\mysql\connector\connection.py", line 490, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
File "C:\Users\Donchaka\AppData\Roaming\Python\Python37\site-packages\mysql\connector\connection.py", line 395, in _handle_result
raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
# creating a TABLE
db = mysql.connector.connect(host="localhost",user="root",password="",database="testdb")
cursor = db.cursor()
cursor.execute("CREATE TABLE People (Name varchar(50), Age int, City varchar(50)")
答:
0赞
lookpix3000 lxx
11/18/2023
#1
我看到您的 SQL 语法缺少 CREATE TABLE 命令的右括号。
下面是更正后的 SQL 语句:CREATE TABLE People (Name varchar(50), Age int, City varchar(50));
评论
1赞
Tim Roberts
11/18/2023
StackOverflow 中的准则是,我们不为简单的印刷错误提供答案,因为这些错误不能成为良好的长期候选者。我们添加评论并投票以结束问题。
上一个:神经网络中用于异或数据的反向传播
评论