- # -*- coding: UTF-8 -*-
- # Author: wt
- import pymysql
- import pandas as pd
- import os
- import time
- import datetime
- def acquire_mysql_data(num_before, num_after, date):
- conn = pymysql.connect(host='host_ip',
- user='blued',
- password='passwd',
- database='db',
- charset='utf8')
- coursor = conn.cursor()
- path = './'
- fname = 'feed_comment_data/'
- if not os.path.exists(path + fname):
- os.makedirs(path + fname)
- f = open(path + fname + str(date) + '.txt', 'a')
- num = coursor.execute(str('select comment_uid,comment_status,comment_timestamp from feed_comment where comment_timestamp<' + str(num_after) + ' and comment_timestamp>=' + str(num_before)))
- data = coursor.fetchall()
- f.write(str(data))
- f.close()
- .....