python如何连接MySQL数据库
#!/usr/bin/env python
# -*-coding:UTF-8-*-#这一句告诉python用UTF-8编码
#=========================================================================
#
# NAME: Python MySQL test
#
# AUTHOR: benyur
# DATE : 2004-12-28
#
# COMMENT: 这是一个python连接mysql的例子
#
#=========================================================================
"""
***** This is a MySQL test *****
select:
conn=Connection()
conn.select_db('test')
cur=conn.cursor()
cur.execute('select * from user')
cur.scroll(0)
row1=cur.fetchone()
row1[0]
row1[1]
row1[2]
insert:
cur.execute('insert into user (name,passwd) values('benyur','12345')')
cur.insert_id()
update:
cur.execute('update user set passwd='123456' where name='benyur'')
delete:
cur.execute('delete from user where id=2')
**********************************
"""
from MySQLdb import *
def conn():
conn=Connection()
conn.select_db('test')
cur=conn.cursor()
cur.execute('select * from user')
cur.scroll(0)
row1=cur.fetchone()
row1[0]
row1[1]
row1[2]
def usage():
print __doc__
if __name__=='__main__':
usage()
MySQLdb下载地址:http://sourceforge.net/projects/mysql-python/
下载解压缩后放到%Python_HOME%Libsite-packages目录中,python会自动找到此包。
MySQLdb基本上是MySQL C API的Python版,遵循Python Database API Specification v2.0。
相关文档:
这个代码是基于python3.0写的,有许多不完善的地方,请自已修改。
# coding: utf-8
from tkinter import *
root = Tk()
root.title("python3.0查询")
#root.minsize(800,600)
#填充无用空间
Label(root).grid(ipady=5)
#11面板
class Frame11:
def __init__(self, root): # ......
昨天和同学闲聊时,谈到了数据库的引擎是什么,今天在网上搜索了很久,也没有发现比较全面的说明各个数据库的搜索引擎方面的.
MySQL引擎是什么,
MySQL是我们比较常用的一种数据库软件。它有着诸多的优点,如开源的,免费的等等。其实它还有一个很好的特点,那就是有多种引擎可以供你选择。如果赛车手能根据不同的路况,地形 ......
修正一下:我在Windows下的实际操作如下
1.关闭正在运行的MySQL。
2.打开DOS窗口,转到mysql\bin目录。
3.输入mysqld解 --skip-grant-tables回车。如果没有出现提示信息,那就对了。
4.再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。
5.输入mysql回车,如果成功,将出现MySQL ......
编辑my.cnf文件,加入:
log-slow-queries[=file] #默认为data目录下的hostname-slow.log文件
long_query_time=10 (seconds) #慢查询的threshold
log-queries-not-using-indexes #记录不使用索引的查询
mysqldumpslow命令获得日志中显示的查询摘要来处理慢查询� ......
MYSQL中只有INNODB和BDB类型的数据表才能支持事务处理!其他的类型是不支持的!
$lnk = mysql_connect("localhost", "root", "");
mysql_select_db("test");
mysql_query("BEGIN");
$query = mysql_query("INSERT INTO test VALUES(1, 'yangjun')&quo ......