62 lines
1.2 KiB
Python
62 lines
1.2 KiB
Python
|
# -*- coding:utf-8 -*-
|
||
|
import _load
|
||
|
|
||
|
import faker_data
|
||
|
import yaml
|
||
|
import codecs
|
||
|
|
||
|
import jaydebeapi
|
||
|
from schedule import every, repeat, run_pending
|
||
|
from pathlib import Path
|
||
|
from datetime import datetime
|
||
|
|
||
|
|
||
|
# 定义公共的部分
|
||
|
path = Path(__file__)
|
||
|
configfile = path.parent.parent / "etc/test_config.yml"
|
||
|
db_config = yaml.load(codecs.open(configfile ,'r',encoding='utf-8'),Loader=yaml.FullLoader)
|
||
|
driver_name = db_config["driver_name"]
|
||
|
driver_jar_path = db_config["driver_jar_path"]
|
||
|
db_user = db_config["db_user"]
|
||
|
db_password = db_config["db_password"]
|
||
|
jdbc_url = db_config["jdbc_url"]
|
||
|
|
||
|
OAuth = [str(db_user),str(db_password)]
|
||
|
if not db_user and not db_password:
|
||
|
OAuth = None
|
||
|
#conn to db by jaydebeapi
|
||
|
conn = jaydebeapi.connect(driver_name,
|
||
|
jdbc_url,
|
||
|
OAuth,
|
||
|
driver_jar_path)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
@repeat(every(2).seconds)
|
||
|
def create_table():
|
||
|
print("create_table ....")
|
||
|
|
||
|
|
||
|
@repeat(every(20).seconds)
|
||
|
def insert_data():
|
||
|
print("insert_data ....")
|
||
|
|
||
|
|
||
|
@repeat(every(5).seconds)
|
||
|
def dalete_data():
|
||
|
print("dalete_data....")
|
||
|
|
||
|
|
||
|
@repeat(every(6).seconds)
|
||
|
def updata_data():
|
||
|
print("updata_data ....")
|
||
|
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
while True:
|
||
|
run_pending()
|