39 lines
1.2 KiB
Python
39 lines
1.2 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(error, idea, site, n_type, n_name, date, title):
|
||
|
with psycopg2.connect(G2) as connection:
|
||
|
with connection.cursor() as cursor:
|
||
|
id = uuid.uuid4()
|
||
|
cursor.execute(
|
||
|
"insert into dashboard_wrongly(id,error, idea, site, n_type, n_name, date, title,url) values (%s,%s,%s,%s,%s,%s,%s,%s,null )"
|
||
|
, (str(id),error, idea, site, n_type, n_name, date, title))
|
||
|
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)
|
||
|
error = r[0]
|
||
|
idea = r[1]
|
||
|
site = r[2]
|
||
|
n_type = r[3]
|
||
|
n_name = r[4]
|
||
|
date = r[5]
|
||
|
title = r[6]
|
||
|
|
||
|
|
||
|
insert_shixiaoxingjiance(error, idea, site, n_type, n_name, date, title)
|