zoukankan      html  css  js  c++  java
  • 往mysql插入大量迁移测试数据

    CREATE TABLE userinfo
    (
    id varchar(10),
    word varchar(10),
    num int
    )
    

     

    python插入 

    # -*- coding: utf-8 -*-
    """
    Spyder 编辑器
    """
    
    import random
    import itertools as its
    import random
    import pymysql
    
    def exec():
        
        db = pymysql.connect(host="192.168.122.8", port=30006, password="123456", user="root", 
                             database="ysp", charset="utf8")
        cursor = db.cursor()
        
        nums = "12345678901234567890123456"
        word = "abcdefghijklmnopqrstuvwxyz"
        r = its.product(word, repeat=5)
        s = its.product(nums, repeat=5)
        
        sql = "INSERT INTO userinfo(id, word, num) VALUES (%s, %s, %s);"
        for i in r:
            si = "".join(i)
            for j in s:
                sj = "".join(j)
                cur = random.randint(1, 100)
                cursor.execute(sql, [si, sj, cur])
                break;
        
        db.commit()
        cursor.close()
        db.close()
        
    if __name__ == '__main__':
        exec()
    

      

  • 相关阅读:
    jsp第四次
    jsp第二次作业
    jsp第一次作业
    软件测试课堂练习
    11.11日
    10.28
    10.25
    10.21
    jsp第七周作业
    JSP第六周作业
  • 原文地址:https://www.cnblogs.com/yspworld/p/13536408.html
Copyright © 2011-2022 走看看