利用Python创建链接mysql数据库个性化对象
来源:互联网 发布:w7 mysql更改密码 编辑:程序博客网 时间:2024/06/15 09:59
import pymysqlclass Sql: db = None cursor = None def __init__(self): print('connecting to mysql...') self.db = pymysql.connect("localhost", "root", "root", "edu", charset="utf8") self.cursor = self.db.cursor() print('connected!') def select(self,selectSql): try: results = self.cursor.execute(selectSql) res = self.cursor.fetchmany(results) return res except: print("Select error: unable to fecth data!") def update(self,updateSql): try: self.cursor.execute(updateSql) self.db.commit() except: print("Update error: unable to update data!") def delete(self,deleteSql): try: self.cursor.execute(deleteSql) except: print("Delete error:unable to delete data!") def getCursor(self): return self.cursor def closedb(self): # 关闭数据链接 self.db.close()
阅读全文
0 0
- 利用Python创建链接mysql数据库个性化对象
- 利用Python创建链接mysql数据库个性化对象
- python链接Mysql数据库
- python链接mysql数据库
- Python链接Mysql数据库
- Python链接Mysql数据库
- python 链接MySQL数据库
- python链接Mysql数据库
- python 创建mysql数据库
- Python使用链接Mysql数据库
- python-MySQL学习笔记-第一章链接到并创建数据库
- 初学mysql & python & python链接数据库(mysql) & mysql for linux
- Python中链接MySql数据库的配置
- 利用Navicat for Mysql创建数据库
- Python利用pymssql访问mysql数据库
- 利用MySQLDriverCS链接MySQL数据库及中文乱码问题
- 创建mysql数据库的PDO对象
- Python学习笔记9-Python 链接MySql数据库
- 【Linux学习笔记】33:环境变量配置文件简介
- 机器学习和计算机视觉库
- 【Java基础】概述
- [POI2000]病毒 [洛谷]P2444
- Codeforces849A Odds and Ends
- 利用Python创建链接mysql数据库个性化对象
- spark partitioner使用技巧
- 二叉树的最大深度
- JSP的7个动作指令
- jmeter解决响应数据乱码问题
- C# winform把新值写入app.config文件
- (六)Interacting with Other Apps与其他应用进行交互
- 什么是事件委托?
- 红黑树插入算法调整的一些原则