newmediamonitoring/import_时效性监测.py

42 lines
1.5 KiB
Python
Raw Normal View History

2020-10-23 00:50:51 +00:00
# -*- coding: utf-8 -*-
import csv
import uuid
import os
import psycopg2
# G1 = 'host=210.77.68.250 port=5432 dbname=g214_test user=g214 password=g214G214'
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert_shixiaoxingjiance(n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start, end):
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
2020-11-02 13:51:05 +00:00
"insert into dashboard_timelinessmonitoring(id,n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start_data,end_data,comment,date) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,null ,'2020-08-01' )"
2020-10-23 00:50:51 +00:00
, (str(id), n_type, n_name, o_type, o_name, city, counties, remark, results, update,silet,start,end))
connection.commit()
if __name__ == '__main__':
2020-11-02 13:51:05 +00:00
with open('/home/xieshen/data/时效性监测临时表.csv', encoding='utf-8') as csvfile:
2020-10-23 00:50:51 +00:00
reader = csv.reader(csvfile)
for r in reader:
print(r)
n_type = r[0]
n_name = r[1]
o_type = r[2]
o_name = r[3]
city = r[4]
counties = r[5]
remark = r[6]
results = r[7]
update = r[8]
silet = r[9]
start = r[10]
end = r[11]
insert_shixiaoxingjiance(n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start, end)