mysql select 报错

代码片段:

     sql_url = "select * from webpage where url = ‘%s‘" % b

     try:
         cursor.execute(sql_url)
         results = cursor.fetchall()
     except Exception, e:
         print e
         pass

系统:centos

语言:python

报错信息:

(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 ‘‘‘‘ at line 1")

报错信息说 在‘“‘附近有语法错误,

但是大部分数据都很顺利的跑起来,然后我把错误时候的那条数据给打印出来,发现那个url后面有 xxx=‘xxxxxxxx‘

所以把这个url塞进sql语句,就成了 select * from webpage where url =‘http://www.baidu.com/index.html?xxx=‘xxxxxxxxx‘‘

哈哈,看出来了吧?

那个参数的后单引号和url的后单引号合并在一起了,本来是2个的,结果成1个了。

正确的写法是:

sql_url = ‘select * from webpage where url = "%s"‘ % b
时间: 2024-08-14 06:01:42

mysql select 报错的相关文章

【Mysql】—— 报错:Can't call commit when autocommit=true

java.sql.SQLException: Can't call commit when autocommit=true at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931) at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.jav

mysql启动报错

mysql启动报错的原因常见的有一下几种: 1.数据所在分区满了 2.pid所在目录mysql用户没有写权限 3.存储引擎为innodb引擎,这个时候启动的时候需要恢复所有的操作(select,create,drop,insert.update,delete),当不能有效的执行恢复操作的时候,mysql启动报错 早上来上班的时候,被通知整栋大楼要停电,想了一下,公司机房还放了几台测试机,如果突然断电的话,会导致测试机中的虚拟机不可用,赶紧一台一台关机吧,其中有一台虚拟机上装着mysql,先进去把

mysql导入报错 ERROR 1286 (42000) at line 1: Unknown table engine 'InnoDB'

[[email protected] mysql]# mysql -u root -p'123456'  jiang < schema.sql                 ERROR 1286 (42000) at line 1: Unknown table engine 'InnoDB' mysql> select * from ENGINES; +------------+---------+-----------------------------------------------

mysql导入报错Variable &#39;sql_notes&#39; can&#39;t be set to the value of &#39;NULL&#39;

报错信息: 执行的SQL语句出错: /*!40111 SET [email protected]_SQL_NOTES */ 错误信息:Variable 'sql_notes' can't be set to the value of 'NULL' 检查: 错误信息是说sql_notes不能设置为null值,登录检查如下 mysql> select @@sql_notes; +-------------+ | @@sql_notes | +-------------+ |       1 | +-

mysql uodate 报错 You can&#39;t specify target table &#39;**&#39; for update in FROM clause

You can't specify target table 'sc' for update in FROM clause 背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面的sql是我写的,执行就报这个错,这个原因说的是 不能从自己表里查数据再更新自己 解决方法:嵌套一层中间表 update sc set sc.score = (select t1.score from (select avg(sc1.score) score from sc sc1 where sc

mysql - sql报错You can&#39;t specify target table &#39;table_name&#39; for update in FROM clause

今天写了个更新数据库表的语句,本意是根据某个条件,筛选出该表某些数据之后,对这些数据进行删除操作,如下 delete from t_person where id in (select id from t_person where name = "hello"); 然而却报错: You can't specify target table 't_person' for update in FROM clause 以下这篇博客( https://blog.csdn.net/qq_2967

mysql编译报错

1.make报错现象 Warning: Bison executable not found in PATH 解决办法 yum -y install bison 2.make报错现象 ake Error at /usr/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:17 (get_filename_component):get_filename_component called with incorrect number of argumen

mysql安装报错

如果编译时出现了以下错误:checking for tgetent in -ltermcap- nochecking for termcap functions library- configure: error: No curses/termcap library found说明 curses/termcap 库没有安装去下载一个ncurses-5.6.tar.gz,wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gztar zx

启动MYSQL 57 报错“The service MYSQL57 failed the most recent........等”的问题解决方式!

每天开机之后,启动MYSQL Notifier就报错,第一次出现重启电脑后解决,后面的几天老是出现,重启电脑好几次都没有解决,感觉很烦人,一定要搞定这个问题找到原因,于是有了下文....... 启动MYSQL 57报错信息"The service MYSQL57 failed the most recent status change request with the message time out has expired and the operation has not been comp