Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 编程错误:您的SQL语法有错误;在1号线_Mysql_Python 3.x_List - Fatal编程技术网

Mysql 编程错误:您的SQL语法有错误;在1号线

Mysql 编程错误:您的SQL语法有错误;在1号线,mysql,python-3.x,list,Mysql,Python 3.x,List,编程错误:您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以获取第1行“”附近要使用的正确语法 当我试图将从列表中提取的web数据导入mysql上的数据库时,这个错误不断发生。我不知道如何补救,我尝试过在字符串输入周围添加“”,但似乎没有任何效果 for container in listings: #extracting price price = container.div.div.strong.text price = price.strip('AMV

编程错误:您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以获取第1行“”附近要使用的正确语法

当我试图将从列表中提取的web数据导入mysql上的数据库时,这个错误不断发生。我不知道如何补救,我尝试过在字符串输入周围添加“”,但似乎没有任何效果

for container in listings:
    #extracting price
    price = container.div.div.strong.text
    price = price.strip('AMV: €')
    price = price.strip('Reserve: €')
    price = price.replace(',', "")
    price = int(price)
    p_list.append(price)

    #location
    location = container.div.find("a", {"class":"PropertyInformationCommonStyles__addressCopy-- 
    link"}).text
    n_list.append("'"+location+"'")
    #house type
    house = container.div.find("div", {"class":"QuickPropertyDetails__propertyType"}).text
    h_list.append("'"+house+"'")
    #number of bathrooms
    bath_num = container.div.find("div", {"class":"QuickPropertyDetails__iconCopy-- 
    WithBorder"}).text
    #makes str and int
    bath_num = int(bath_num)
    ba_list.append(bath_num)
        #number of bedrooms
    bed_num = container.div.find("div", {"class":"QuickPropertyDetails__iconCopy"}).text
    bed_num = int(bed_num)
    be_list.append(bed_num)
    #makes str and int
    all_var.append((price, location, house, bath_num, bed_num))
    #connecting to database     
import mysql.connector

d_b = mysql.connector.connect(host = "localhost", user = "MY_ACCOUNT", passwd = "MY_PASSWORD", database 
= "daftdatabase",)
print(d_b)
mycursor = d_b.cursor()
#create database
#mycursor.execute("CREATE DATABASE daftdatabase")
#create table
#mycursor.execute("CREATE TABLE DaftTable(price Integer(10), location VARCHAR(50), type VARCHAR(20), bedrooms INTEGER(2),  bathrooms INTEGER(2))")
show_table = mycursor.execute("SHOW TABLE")

for var in all_var:
data = mycursor.execute("INSERT INTO DaftTable(price, location, type, bathrooms, bedrooms) 
VALUES"+var)

真的不知道该怎么做,任何帮助都将被感激

正确的MySQL语句是(注意复数形式),而不是
showtable

只是一个提示:在这里共享登录凭据不是一个好主意。建议编辑到一些通用的内容,例如:user='foo',passwd='bar'您没有从VARCHAR行开始正确插入引号。。。你必须记住python也看到了这些引用。@create table行中的Rashid'Lee'Ibrahim?@Adriankennely实际上又看了一遍。。。基本上,“mycursor=d_b.cursor()”行下面的所有内容都是python的语法错误。您需要将其放在一个变量中,然后在db上执行该变量cursor@Rashid李·易卜拉欣你能详细解释一下吗?将哪个放在变量中,如下面所有代码行中?Sorry我改变了这一点,然后在我将元组更改为字符串后,有关元组的错误必须是字符串发生了此错误:InternalError:Unread result Found这是一个完全不同的错误,此问题中的错误正在解决。你应该接受我的正确答案,并用你的新错误发布一个新问题。