mysql常用语句(python)

版权声明:转载的说一下 https://blog.csdn.net/weixin_44465571/article/details/86215300

连接数据库

import pymysql
mysql = pymysql.connect(user="root",password="qq123456",db="hanhan")
cou = mysql.cursor()

插入语句

    sql = """insert into sss(title,times) VALUES ('%s','%s')"""%(title,times)
    cou.execute(sql)
    mysql.commit()

 sql = "insert into sss(title,`time`,) VALUES ('"+title+"','"+time+"')"
        cursor.execute(sql)
        db.commit()

    sql = """insert into sss VALUES (0,'%s','%s')"""%(title,times)
    cou.execute(sql)
    mysql.commit()

猜你喜欢

转载自blog.csdn.net/weixin_44465571/article/details/86215300