#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
#打开数据库链接
db = MySQLdb.connect("localhost","root","abc123","tests")
#使用cursor()方法操作来获取游标
cursor = db.cursor()
#使用execute方法执行SQL语句
cursor.execute("SELECT VERSION()")
#使用fetchone()方法获取一条数据库
data = cursor.fetchone()
print "Database version :%s"% data
#关闭数据库链接db.close()
相关文章
- WNMP环境搭建步骤 nginx1.4.3+php-5.3.27+mysql-5.5+RunHiddenConsole
- Mysql5.7自定义函数递归报错1424 Recursive stored functions and triggers are not allowed
- 有关使用phpstudy搭建sqli-lab环境搭建时发生Uncaught Error: Call to undefined function mysql_connect()错误
- mysql if()
- mysql错误一例:ERROR 1030 (HY000): Got error 28 from storage engine
- 微信小程序 实现websocket长连接 以及断开连接之后自动重连
- 雨露均沾的OkHttp—WebSocket长连接的使用&源码解析
- 实现单台测试机6万websocket长连接
- Spring+Stomp+ActiveMq实现websocket长连接
- Django websocket 长连接使用