Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/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文件并将其';使用Python创建目录_Python_Mysql - Fatal编程技术网

插入mysql文件并将其';使用Python创建目录

插入mysql文件并将其';使用Python创建目录,python,mysql,Python,Mysql,我想结合使用Python将文件名和目录插入MySql表 代码 cursor.execute("Insert INTO library (book_name, author, written, book_link, images) VALUES (%s, %s, %s, 'library/'%s, 'images/'%s )" , (book_name, author, written, book_link, images)) cursor.execute(“插入到库中(书名、作者、已写、书链接、

我想结合使用Python将文件名和目录插入MySql表

代码

cursor.execute("Insert INTO library (book_name, author, written, book_link, images) VALUES (%s, %s, %s, 'library/'%s, 'images/'%s )" , (book_name, author, written, book_link, images)) cursor.execute(“插入到库中(书名、作者、已写、书链接、图像)”值(%s、%s、'library/'%s、'images/'%s)”,(书名、作者、已写、书链接、图像)) 给我不需要的单引号
符号,如下所示:

images/'me library/'my life

如何避免这种错误语法?

CONCAT('library/',%s)
,或者将
'library/'
前置到
book\u link
的值,等等(“插入到库(book\u name,author,writed,book\u link,images)值(%s,%s,CONCAT('library/',%s),CONCAT('images/',%s)),(bookname,author,writed,book\u link,images))-这很好用。非常感谢你!