python遍历数据库表及其相关表操作,python数据库,python遍历数据库表
python遍历数据库表及其相关表操作,python数据库,python遍历数据库表
python遍历数据库表及其相关表操作.
相关文章推荐:
Python 并行遍历zip()函数使用方法
Python遍历文件夹目录与文件操作
#!/usr/bin/pythonimport MySQLdbimport getoptimport sysfrom datetime import datetimeconf_host = '127.0.0.1'conf_port = 3306conf_user = 'root'conf_pass = ''conf_db = 'information_schema'conf_bind_db = 'mydns'def main(): db_bind = MySQLdb.connect(host = conf_host, port = conf_port, user = conf_user, passwd = conf_pass, db = conf_bind_db) cursor_bind = db_bind.cursor() db = MySQLdb.connect(host = conf_host, port = conf_port, user = conf_user, passwd = conf_pass, db = conf_db) cursor = db.cursor() file = open("output.txt","w") cursor.execute("select table_name from tables where table_name regexp'rg_' and table_schema ='" + conf_bind_db + "';") #www.iplaypy.com for row in cursor.fetchall(): print row[0] sql = "select zone,host,type,data,ttl from " + row[0] + " where zone regexp'(cnc|ct|edu|ov).centos.com' and data='originboss.centos.com.' and type='cname';" cursor_bind.execute(sql) result = cursor_bind.fetchall() for row in result: print row[0],row[1],row[2],row[3],row[4] cursor.close() db.close() cursor_bind.close() db_bind.close() if __name__ == '__main__': main()
编橙之家文章,
相关内容
- python方法恢复整理修改过java包,pythonjava,python方法恢复
- python子网掩码格式转换工具源代码,python子网掩码,py
- 用Python方法对Cursor进行扩展,pythoncursor扩展,用Python方法
- 最简易的python计算器实现源代码,python计算器源代码
- tornado web url路由配置扩展,tornadourl,tornado web
- 教你用python随机生成固定长度字符串的方法,python字符
- 初学者用python爬凡客图片的源码,,python学习最大的动
- Python解一元一次方程简单方法,python一元一次方程,用
- Python实现分词处理的示例,python分词示例,Python实现分词
- Sleep和Sort的结合应用小游戏,sleepsort小游戏,想知道自己
评论关闭