Exemplo n.º 1
0
 def truncateTable(self):
     sql_truncate = 'truncate table '
     sql_list = []
     for i in self.schemaName:
         for j in self.tableName:
             sql_list.append(sql_truncate + str(i) + '.' + str(j) + ';')
     print(sql_list)
     pg = pypgsql.dba()
     pg.execListSql(sql_list)
Exemplo n.º 2
0
def employee():
    api_method = 'employee/v2/queryEmployee'
    # api_bodyValue= ''
    km = KangMian(api_method, '{}')
    responseData = km.callAPI()
    emp = ParseEmployee()
    sqlDict, colDict = emp.getTabAndSql_Dict()

    list_sql = Util.dealResponseData(responseData, sqlDict, colDict)
    print(len(list_sql))
    pg = pypgsql.dba()
    pg.execListSql(list_sql)
Exemplo n.º 3
0
 def dealRespnoseData(self):
     # # 全量数据先删除
     # self.truncateTable()
     # 拿到结构
     self.getDataBaseDict()
     responseData = self.callAPI()
     print('返回' + str(responseData) + '条数据')
     if len(responseData) == 0:
         return 0
     list_sql = Util.dealResponseData(responseData, self.sqlDict,
                                      self.colDict)
     print(len(list_sql))
     pg = pypgsql.dba()
     pg.execListSql(list_sql)
     return 1
Exemplo n.º 4
0
def getTableList(schemaName, tableName):
    sql = '''
        select attr.attname
        from pg_attribute as attr
        left join pg_class  as cls on attr.attrelid = cls.oid 
        inner join pg_description as des on attr.attrelid = des.objoid and attr.attnum = des.objsubid
        inner join pg_namespace as ns on cls.relnamespace = ns.oid
        where ns.nspname='%s' and cls.relname='%s' 
        and des.description ~ 'WQ';
    ''' % (schemaName, tableName)
    pg = pypgsql.dba()
    result = pg.execSqlFetchall(sql)
    list_columns = []
    # print(type(result))
    for i in result:
        # print(type(i))
        list_columns.append(i['attname'])
        # print(i['attname'])
    return list_columns
Exemplo n.º 5
0
    def truncateTable(self):
        print('路线拜访, 根据bodyValue删除')
        print(self.bodyValue)
        _body_Value = eval(self.bodyValue)
        try:
            date_start = _body_Value['date_start']
            date_end = _body_Value['date_end']
        except:
            print(' date_start :' + date_start)
            print(' date_end :' + date_end)
            raise ('date_start 和 date_end 数据异常')

        sql_truncate = 'delete from  '
        sql_list = []
        for i in self.schemaName:
            for j in self.tableName:
                sql_list.append(sql_truncate + str(i) + '.' + str(j) +
                                " where left(visit_date,10) between '" +
                                date_start + "' and '" + date_end + "';")
        # print(sql_list)
        pg = pypgsql.dba()
        pg.execListSql(sql_list)
Exemplo n.º 6
0
from lib import Util, pypgsql, common
from lib.ObjectAPI import KangMian
from lib.Modules import Employee
import time

# 查询门店
api_method = 'store/v1/queryStore'
api_bodyValue = '{}'
schemaName = ['api_sftm']
tableName = [
    'store_v1_querystore_dealers', 'store_v1_querystore_deliverys',
    'store_v1_querystore_exts', 'store_v1_querystore_head',
    'store_v1_querystore_linkmans'
]

pg = pypgsql.dba()
sql_truncate = 'truncate table '
for _ in tableName:
    _sql = sql_truncate + schemaName + '.' + _ + ';'
    print(_sql)
    pg.execsql(_sql)

i = 0
while True:
    i += 1
    api_bodyValue = '{"page_number":"' + str(i) + '"}'
    print(api_bodyValue)
    # exit(0)
    km = KangMian(api_method, api_bodyValue)
    # 拿到ResponData
    responseData = km.callAPI()