123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import threading
- import pymysql
- import pandas as pd
- from sqlalchemy import create_engine
- db = pymysql.connect(host='localhost',
- user='root',
- port=3307,
- password='r6kEwqWU9!v3',
- database='qbh_hlfx_backup')
- fre = '1d'
- cursor = db.cursor()
- cursor.execute('show tables like {}'.format('\'%{}\''.format(fre)))
- stk = threading.local()
- def hlfx(table_list, engine, tosql):
- for table in table_list:
-
-
- print(engine)
- print(tosql)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- table_list = ['stk002237_1d','stk000004_1d']
- step = 50
- thread_list = []
- engine = []
- tosql = []
- for i in range(0, len(table_list), step):
- engine.append(create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/qbh_hlfx_backup?charset=utf8'))
- tosql.append(create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/bb22?charset=utf8'))
- threading.Thread(target=hlfx, args=(table_list[i:i + step], engine[i], tosql[i],)).start()
|