34 lines
954 B
Python
34 lines
954 B
Python
#!/usr/bin/env python
|
|
# -*- coding: UTF-8 -*-# enable debugging
|
|
import os, signal, openpyxl, re, pymysql, time, logging, datetime
|
|
from openpyxl.workbook import Workbook
|
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font, colors, Color
|
|
|
|
def getToday() :
|
|
today = datetime.datetime.now()
|
|
todayStr = today.strftime('%Y%m%d')
|
|
return todayStr
|
|
|
|
def filename(todayStr) :
|
|
filename = '/var/www/html/dicDump/' + todayStr + '_synonyms.xlsx';
|
|
return filename
|
|
|
|
wb = Workbook()
|
|
ws = wb.active
|
|
ws.title = "동의어_" + getToday()
|
|
|
|
conn = pymysql.connect(host='localhost', user='root', password='dlsxjvkzmdkdlakzpt!',db='searchdic', unix_socket='/var/run/mysqld/mysqld.sock', charset='utf8')
|
|
|
|
curs = conn.cursor()
|
|
sql = "SELECT * FROM `SYNONYM_OUTPUT`"
|
|
curs.execute(sql)
|
|
rows = curs.fetchall()
|
|
|
|
for i in range(len(rows)) :
|
|
#print(rows[i][0])
|
|
ws['A' + str(i+1)] = rows[i][0]
|
|
|
|
wb.save(filename = filename(getToday()))
|
|
|
|
conn.close()
|