43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
import csv
|
||
|
import uuid
|
||
|
import os
|
||
|
import psycopg2
|
||
|
|
||
|
from pip._vendor import chardet
|
||
|
|
||
|
# 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(
|
||
|
"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 ,null )"
|
||
|
, (str(id), n_type, n_name, o_type, o_name, city, counties, remark, results, update,silet,start,end))
|
||
|
connection.commit()
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
|
||
|
with open('D:/2020/舆论监测平台/XMTJC/数据/时效性监测临时表.csv', encoding='utf-8') as csvfile:
|
||
|
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)
|