#更改数据库
This commit is contained in:
parent
5b1d76639c
commit
b69741bf1e
|
@ -663,3 +663,72 @@ class CheckCode(models.Model):
|
||||||
phone_code = models.CharField('手机验证码', max_length=256, null=True, blank=True)
|
phone_code = models.CharField('手机验证码', max_length=256, null=True, blank=True)
|
||||||
phone = models.CharField('电话号', max_length=256, null=True, blank=True)
|
phone = models.CharField('电话号', max_length=256, null=True, blank=True)
|
||||||
c_time = models.DateTimeField('时间', auto_now_add=True)
|
c_time = models.DateTimeField('时间', auto_now_add=True)
|
||||||
|
|
||||||
|
|
||||||
|
#新媒体舆情临时表
|
||||||
|
class NewmediaSentimentWeixin(models.Model):
|
||||||
|
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||||
|
code = models.CharField('公众号',max_length=256,null=True,blank=True)
|
||||||
|
title = models.CharField('标题',max_length=256,null=True,blank=True)
|
||||||
|
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
|
||||||
|
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
|
||||||
|
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
class NewmediaSentimentWeibo(models.Model):
|
||||||
|
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||||
|
code = models.CharField('微博号',max_length=256,null=True,blank=True)
|
||||||
|
title = models.CharField('标题',max_length=256,null=True,blank=True)
|
||||||
|
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
|
||||||
|
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
|
||||||
|
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
class NewmediaSentimentToutiao(models.Model):
|
||||||
|
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||||
|
code = models.CharField('头条号',max_length=256,null=True,blank=True)
|
||||||
|
title = models.CharField('标题',max_length=256,null=True,blank=True)
|
||||||
|
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
|
||||||
|
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
|
||||||
|
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
#时效性监测临时表
|
||||||
|
class TimelinessMonitoring(models.Model):
|
||||||
|
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4())
|
||||||
|
n_type = models.CharField('新媒体类型',max_length=256,null=True,blank=True)
|
||||||
|
n_name = models.CharField('新媒体名称',max_length=256,null=True,blank=True)
|
||||||
|
o_type = models.CharField('主体类型',max_length=256,null=True,blank=True)
|
||||||
|
o_name = models.CharField('主体名称',max_length=256,null=True,blank=True)
|
||||||
|
city = models.CharField('市',null=True,blank=True,max_length=256)
|
||||||
|
counties = models.CharField('县区',max_length=256,null=True,blank=True)
|
||||||
|
remark = models.CharField('备注',max_length=256,null=True,blank=True)
|
||||||
|
results = models.CharField('监测结果',max_length=256,null=True,blank=True)
|
||||||
|
update = models.CharField('更新次数',max_length=256,null=True,blank=True)
|
||||||
|
silet = models.CharField('最大连续静默日数',max_length=256,null= True,blank=True)
|
||||||
|
start_data = models.CharField('开始时间',max_length=256,null=True,blank=True)
|
||||||
|
end_data = models.CharField('结束时间',max_length=256,null=True,blank=True)
|
||||||
|
comment = models.CharField('评论次数',max_length=256,null=True,blank=True)
|
||||||
|
date = models.CharField('最近更新时间',max_length=256,null=True,blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.n_name
|
||||||
|
|
||||||
|
#错别字临时表
|
||||||
|
class Wrongly(models.Model):
|
||||||
|
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||||
|
error = models.CharField('错误',max_length=256,null=True,blank=True)
|
||||||
|
idea = models.CharField('建议',max_length=256,null=True,blank=True)
|
||||||
|
site = models.TextField('上下文',null=True,blank=True)
|
||||||
|
n_type = models.CharField('新媒体类型',max_length=256,null=True,blank=True)
|
||||||
|
n_name = models.CharField('新媒体名称',max_length=256,null=True,blank=True)
|
||||||
|
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
|
||||||
|
title = models.CharField('标题',max_length=256,null=True,blank=True)
|
||||||
|
url = models.CharField('URL',max_length=256,null=True,blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- 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)
|
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- 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)
|
Loading…
Reference in New Issue