【问题标题】: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 ')您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在 ') 附近使用的正确语法
【发布时间】:2020-03-24 15:25:28
【问题描述】:
from bs4 import BeautifulSoup
import requests
import mysql.connector

my_db = mysql.connector.connect(
    host = "localhost",
    user = "root",
    password = "mypassword",
    database =  "findingimdbscore",
)
my_cursor = my_db.cursor()

my_cursor.execute("CREATE TABLE IF NOT EXISTS film_ve_puan (film_name VARCHAR(100),ImbdScore DOUBLE(4),film_id INTEGER AUTO_INCREMENT PRIMARY KEY)")

所有变量的颜色都改变了,但是film_id 没有改变

【问题讨论】:

  • 为什么我会出现这个错误 idk?请帮助
  • DOUBLE(4) 更改为DOUBLE
  • @khelwood 感谢你的朋友,我非常感谢

标签: python mysql python-3.x


【解决方案1】:

DOUBLE(4) 不是合法的 MySQL 类型。 您可以使用FLOAT(4) 或仅使用DOUBLE

CREATE TABLE film_ve_puan (
  film_name VARCHAR(100),
  ImbdScore DOUBLE,
  film_id INTEGER AUTO_INCREMENT PRIMARY KEY
)

https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html

【讨论】:

    【解决方案2】:

    我认为您应该将 DOUBLE(4) 更改为仅 DOUBLE

    【讨论】:

      猜你喜欢
      • 2011-08-07
      • 2012-05-02
      • 2013-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多