python操作数据库
2017-08-08 12:01
267 查看
#!/usr/bin/env python #encoding:utf-8 import MySQLdb print "<html>" print "<body>" print "<h1>book</h1>" print "<ul>" connection = MySQLdb.connect(user="root", passwd="123456", db="zabbix") cursor = connection.cursor() cursor.execute("SELECT * FROM users") for row in cursor.fetchall(): print "<li>%s</li>" % row[0] print "</ul>" print "</body></html>"
[root@bogon ~]# python mysql.py <html> <body> <h1>book</h1> <ul> <li>1</li> <li>2</li> </ul> </body></html> [root@bogon ~]#yum install MySQL-python
相关文章推荐
- python操作三大主流数据库(2)python操作mysql②python对mysql进行简单的增删改查
- 学习python 第三季:编写简单简单连接数据库并执行查询操作
- mongo数据库基本操作--python篇
- Django使用Python操作数据库 --Django 1.8.2 文档(中文)部分笔记
- Python3.x的mysqlclient的安装、Python操作mysql,python连接MySQL数据库,python创建数据库表,带有事务的操作,CRUD
- 【python】数据库操作
- Python 操作Oralce数据库
- Python:操作PostgreSQL数据库(使用PyGreSQL)
- python orm框架SQLAlchemy简单应用(数据库操作)
- python 操作 postgreSQL 数据库 Demo ( 基于PyGreSQL 包)
- Python 操作 mongodb 数据库
- python:数据库连接操作入门
- 【忽略】Python操作数据库
- Python中操作mongo数据库
- Python数据库操作(MySQL)
- python小白-day9 数据库操作与Paramiko模块
- python MySQLdb 操作数据库时中文无返回
- python使用MySQLdb操作数据库
- python连接到SQList数据库以及简单操作
- MySQLdb和Python数据库操作