Python实战之MySQL数据库操作
来源:互联网 发布:淘宝客服工作在哪里找 编辑:程序博客网 时间:2024/05/12 05:02
一、在shell窗口:
安装mysql-python包:
$ sudo yum install MySQL-python
二、在pycharm
安装mysql-python包:file—>setting—>project interpreter—> "+" —>输入mysqldb—>install pakage。
import MySQLdbclass MysqlManager: def openConn(self, hoststr, userStr, passwdStr, tableSchema): try: conn = MySQLdb.connect(host='%s'%(hoststr), user='%s'%(userStr), passwd='%s'%(passwdStr), db='%s'%(tableSchema), port=3306, charset="utf8", use_unicode="True") print "conn = ",conn return conn except Exception,e: print str(e); def select(self): conn = self.openConn("192.168.0.110", "test", "test", "test") cursor = conn.cursor() cursor.execute("SELECT * FROM test") rows = cursor.fetchall() for row in rows: print row cursor.close () conn.close ()mysqlSelect = MysqlManager()mysqlSelect.()
0 0
- Python实战之MySQL数据库操作
- Python实战之MySQL数据库操作
- Python实战之Oracle数据库操作
- Python实战之Oracle数据库操作
- Python实战之Oracle数据库操作
- Python实战之Oracle数据库操作
- Python实战之Oracle数据库操作
- python之mysql数据库操作
- Python之操作MySQL数据库
- mysql数据库操作实战
- MySQL数据库操作实战
- Python编程语言操作MySQL数据库实战演习
- Python编程语言操作MySQL数据库实战演习
- Python编程语言操作MySQL数据库实战演习
- Python之操作MySQL数据库(二)
- 数据库之python+MySQL基本操作
- 主题:MySQL数据库操作实战
- python连接mysql数据库实战
- vs2012 最常用快捷键
- CodeForces 651B Beautiful Paintings
- UVA 11388 (GCD&&LCM 水~)
- 每日一linux命令(10)-------cat
- 学习Content Provider
- Python实战之MySQL数据库操作
- SQL查询---联接---嵌套---计算---分类汇总---量词---谓词---合并
- [LeetCode][8]String to Integer (atoi)解析与模仿Java源码实现 -Java实现
- 开源C++函数库Boost内存池使用与测试
- 利用homebrew 下载android idk
- poj3045.cpp
- 重读COM技术内幕(inside com)有感
- Word Pattern
- Qt Quick 准确的移动平台屏幕适配