python 数据库处理
发表于:2025-11-08 作者:千家信息网编辑
千家信息网最后更新 2025年11月08日,# -*- coding:utf-8 -*-#!/bin/env python'''#Auth:karl#Function: released version#Date:2017/6/27#Versi
千家信息网最后更新 2025年11月08日python 数据库处理
# -*- coding:utf-8 -*-#!/bin/env python'''#Auth:karl#Function: released version#Date:2017/6/27#Version:V1.0'''import sys,re,time,datetimeimport paramikoimport loggingimport ConfigParserimport tracebackimport MySQLdbimport platformimport xlrdreload(sys)sys.setdefaultencoding('utf-8')if "Linux" == platform.system(): Excelpath="/home/appdeploy/version/Version"else: Excelpath = "D:\\auto\\release\Version"class Mysql_connect(object): def __init__(self,*agre): self.port=agre[0] self.passwd=agre[1] self.username=agre[2] self.host=agre[3] self.version=agre[4] def File_get(self): Excelfilepath="{path}_{version}/Filelist.xlsx".format(path=Excelpath,version=self.version) workbook=xlrd.open_workbook(Excelfilepath) booksheet = workbook.sheet_by_name('Sheet1') self.p=list() for row in range(booksheet.nrows): row_data = [] for col in range(booksheet.ncols): cel = booksheet.cell(row, col) val = cel.value try: val = cel.valueval = re.sub(r'\s+', '', val) except: pass if type(val) == float: val = int(val) else: val = str(val) row_data.append(val) self.p.append(row_data) self.__Mysql_deal() def __Mysql_deal(self): try: con = MySQLdb.connect(user=self.username,passwd=self.passwd,db="version_release",port=int(self.port),charset="utf8") dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") cursor=con.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS version(Id INT PRIMARY KEY AUTO_INCREMENT,\ File VARCHAR (30) DEFAULT null,Release_date TIMESTAMP,Instruction text)") sql="""INSERT INTO version (File,Release_date,Instruction) VALUES (%s, %s, %s) """ for value in self.p: valuse=(value[0],dt,value[1]) result=cursor.execute(sql,valuse) cursor.close() con.commit() con.close() except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) def File_deal(self): try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(self.host,22, "root","****", timeout=5) for name in self.p: route_0=name[0] route=name[1] cmd="\cp -vr {path}_{version}/{filename}.xls {dir_new}".format(path=Excelpath,version=self.version,filename=route_0,dir_new=route) stdin, stdout, stderr = ssh.exec_command(cmd) for out_msg in stdout.readlines(): print out_msg except Exception, e: print '%s\tError\n' % (self.host) ,e ssh.close()def main(): agre = ["3306", "*****", "root","xx.xx.xx.xx","3.0"] stg = Mysql_connect(*agre) stg.File_get() stg.File_deal()if __name__ == '__main__': try: main() except Exception as e: print traceback.format_exc()
utf-8
数据
数据库
处理
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
口碑好的软件开发答疑解惑
法学会网络安全法研究会
高性能数据采集服务器
我的世界1.8.9服务器介绍
delphi连接操作数据库
如何在服务器上运行exe
代县天气预报软件开发
数据库加密技术不包括
软件开发测试ipd流程
广州梦想网络技术
直播服务器设置教程
419网络安全讲话内容
有钱还还债软件开发
数据库被加工处理吗
联想服务器web管理
计算机网络安全需要学什么语言
数据库oracle权限
游戏服务器 设计
服务器备案材料
软件开发开发什么软件测试
局域网服务器上网设置
matlab一起画数据库
软件开发数据安全
软件开发测试ipd流程
网络安全大数据培训班
网络安全周个人信
软件开发的投资回报
qq三国得陇望蜀服务器在哪
网络安全活动策划总结
合肥ktv服务器回收厂家