#!/usr/bin/python
# -*- coding:utf-8 -*- # @filename: search
# @author:wwx399777 wuweiji
# @date: 2018/1/25 9:35 import pymysql
import pyecharts
from datetime import datetime
import pandas as pd
import numpy as np
import matplotlib as mpl
import re def connect_mysql(sql, oper_type="select", data_l=None):
conn = pymysql.connect(host='localhost', user="root", password="***",
database="work", port=3306)
cur = conn.cursor()
if oper_type == "insert":
cur.executemany(sql, data_l)
conn.commit()
else:
cur.execute(sql)
result = cur.fetchall()
conn.close()
return result def data_analysis():
sql = """
SELECT p.name, p.email, p.memo from personal_userinfo p
"""
x = connect_mysql(sql)
print(type(x), x)
x = list(x[2])
print(x)
return x data_analysis() def create_list(file_name):
ls = []
if not re.findall(file_name, r".txt"):
file_name += ".txt"
with open(file_name) as f:
for i in f:
name, email, memo = i.strip().split(",")
ls.append([name, email, memo, datetime.utcnow()])
return ls def data_insert():
sql = """
INSERT INTO WORK.personal_userinfo (name, email, memo, date_time) VALUES (%s, %s, %s, %s)
"""
data_l = create_list("person_info")
connect_mysql(sql, oper_type="insert", data_l=data_l) # data_insert()

最新文章

  1. 分享SQL Server 2012/2014内存数据库,AlwaysOn,参考教材与网上总结
  2. JVM的GC概述
  3. Liferay 6.2 改造系列之十四:修改组织的表单内容
  4. iOS键盘出现时界面跟着往上推
  5. centOS6.5安装SUN-jdk7
  6. Java DES 加解密文件
  7. 对SVM的个人理解
  8. caption标签,为表格添加标题和摘要
  9. php转化输入日期为Unix 纪元到当前时间的秒数 日期筛选
  10. if(!!attr)是什么鬼???
  11. Java传参
  12. 【JAVAWEB学习笔记】02_HTML&CSS
  13. Python in/not in --- if not/if + for...[if]...构建List+ python的else子句
  14. vim基本操作
  15. obj-c编程19:关联对象
  16. Oracle下查看索引的语句
  17. 转载:让Windows Server 2012r2 IIS8 ASP.NET 支持10万并发请求
  18. 1、PHP入门二维数组与循环
  19. angular.js学习笔记--概念总结
  20. Sublime 修改快捷键

热门文章

  1. Windows下findstr命令的使用
  2. 关于Android ListView组件中android:drawSelectorOnTop含义(转载)
  3. bzoj 2555: SubString【后缀自动机+LCT】
  4. poj 2774 Long Long Message【SA】
  5. bzoj 1207: [HNOI2004]打鼹鼠【dp】
  6. Luogu P2051[AHOI2009]中国象棋【dp】By cellur925
  7. STL<queue>的使用
  8. php连接mysql并读取数据
  9. Magic Numbers CodeForces - 628D
  10. Math Show CodeForces - 846B