美文网首页
MySQLdb库和pymysql库的区别

MySQLdb库和pymysql库的区别

作者: 朝畫夕拾 | 来源:发表于2019-05-07 09:20 被阅读0次

def  func(self, *args):

self.insert_sql = """insert  into  jobble_article(title, create_date, url, fav_nums)  value(%s, %s, %s, %s)"""% args args(收集参数)是你要输入的值

self.cursor.execute(insert_sql)

MySQLdb只支持Python2.*,还不支持3.*

可以用PyMySQL代替。安装方法:pip install PyMySQL

然后在需要的项目中,把 __init__.py中添加两行:

import pymysql

pymysql.install_as_MySQLdb()

就可以用 import MySQLdb了。其他的方法与MySQLdb一样。

相关文章

网友评论

      本文标题:MySQLdb库和pymysql库的区别

      本文链接:https://www.haomeiwen.com/subject/ldpsoqtx.html