[英]Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb'
[英]MySQLdb Module Python error
我有一个对象的这种方法,可以读取数据库中存在的所有表并返回查询的结果。
def get_tables(self):
self.__cursor.execute('SELECT table_name FROM information_schema.tables where table_schema="{}";)'.format(self.__database))
query_result = self.__cursor.fetchall()
if not self.__cursor.rowcount:
return False
else:
return query_result
该方法是从中调用的:
query_result = get_tables()
for record in query_result:
print record[0]
当我执行脚本时,我会在控制台中看到所需的结果,最后出现此错误:
Exception _mysql_exceptions.ProgrammingError: (1064, "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") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x7fbd06161910>> ignored
我该如何解决?
您的SQL已损坏:
... table_schema="{}";)
删除尾随)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.