pymysql连数据库简单版
2024-09-04 15:56:10
# 导入模块
import pymysql
# 连接数据库
mysql_conn = pymysql.connect(host="127.0.0.1",
port=3306,
user="root",
password="",
charset="utf8",
db="t1")
# 获取游标
c = mysql_conn.cursor(cursor=pymysql.cursors.DictCursor)
# SQL语句
sql = "select * from users WHERE name='jwb' and age=73 "
# 执行SQL
res = c.execute(sql)
# 打印结果
print(c.fetchall())
# 关闭游标
c.close()
# 关闭数据库
mysql_conn.close()
最新文章
- fallacies of distributed computing
- iOS开发者账号配置进行设备调试
- 1019 JDBC链接数据库进行修删改查
- C++的ORM 开源框架
- poj3667【线段树】/【类似权值线段树写法】
- openssh
- bootstrap-datetimepicker在经过GC(Google Closure Compiler)压缩后无法使用的解决方案
- php模拟用户自动在qq空间发表文章的方法
- Web.config配置详解【转 】
- DC-DC芯片 同步和異步方式有什么區別
- C#基础学习第三天(.net菜鸟的成长之路-零基础到精通)
- java Scanner中next和nextLine()区别
- JavaScript之JS单线程|事件循环|事件队列|执行栈
- hdu4419
- bzoj 2844 albus就是要第一个出场 - 线性基
- Django框架的使用
- Android 之 应用未捕获异常处理
- RabbitMQ (十六) 消息队列的应用场景 (转)
- jsp简单实现统计在线人数
- Android开发 使用 adb logcat 显示 Android 日志
热门文章
- js ctrl+v实现图片粘贴
- Android模拟器Genymotion安装apk
- ELF解析(part one)
- 激活modelsim se 10.4 时运行patch_dll.bat不能生成TXT
- web info
- Angularjs学习笔记2_添加删除DOM元素
- Unity学习笔记 - Assets, Objects and Serialization
- CentOS环境下yum安装LAMP
- IOS设计模式的六大设计原则之接口隔离原则(ISP,Interface Segregation Principle)
- Python常见经典 python中if __name__ == '__main__': 的解析