#!/usr/bin/python
-- coding: UTF-8 --
pip install MySQL-python
import MySQLdb, os
try:
conn = MySQLdb.connect(host='172.17.42.1', user='数据库访问用户', passwd='数据库访问密码', db='数据库名', port=3306)
cur = conn.cursor()
cur.execute('SELECT `id`, `name`, `path`, FROM `doc_file`')
# 获取全部记录
results=cur.fetchall()
for r in results:
id, name, path = r[0], r[1], r[2]
if path and not os.path.exists(path):
print 'file not exist: ', id, name, path, flashpath
cur.close()
conn.close()
except MySQLdb.Error,e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])
</pre>
本文由用户 wuxqing 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
本文地址:https://www.open-open.com/code/view/1457829300325
6 个评论
ossaa 1年前
Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such info a lot. I was seeking this particular information for a very long time. Thank you and good luck. the travelers within
pevahanifo 3年前
Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.Carpet Cleaning
cixexey 3年前
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. suzuki coin
wind-zz 4年前
phyton语言
cheonghu 5年前 0
#连接数据库
import pymysql;
# 建立mysql链接
def connectdb():
try:
conn = pymysql.connect(host='192.168.57.30', port=3306, user='root', passwd='root',
db='test', charset='utf8')
except:
print("connect db error")
finally:
return conn
def getAllDataByTemplatId():
try:
conn = db.connectdb()
cur = conn.cursor()
sql = "SELECT * FROM test uvr" cur.execute(sql)
return cur.fetchall()
except: print("some")
finally: print("close db")
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。