从零开始学网络爬虫之数据区MySQL

    xiaoxiao2021-12-15  36

    import MySQLdb conn=MySQLdb.Connect(host='localhost',user='root',passwd='') cursor =conn.cursor() cursor.execute('create database if not exists student') #conn.commit() conn.select_db('student') cursor =conn.cursor() sql = "create table if not exists test1(name varchar(128), age int(4))" # cursor.execute(sql) # #cursor =conn.cursor() sql = "insert into test1(name, age) values ('%s', %d)" % ("zhaowei", 23) try: cursor.execute(sql) except Exception, e: print e
    转载请注明原文地址: https://ju.6miu.com/read-1000010.html

    最新回复(0)