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): # ......
ǰһƪ½²Á˼òµ¥µÄC/C++µ÷ÓÃPython½Å±¾Ä£¿é£¨.py£©¡£¼ÈÈ»ÊÇÓÃÓÚÖî¶àÓÎÏ·³ÌÐòµÄ½Å±¾ÓïÑÔ£¬Äǿ϶¨ÊÇȱ²»ÁË»¥µ÷£¨ÀñÉÐÍùÀ´£©¡£Òò´Ë£¬±¾Æª½²Ò»¸ö¼òµ¥µÄpythonµ÷ÓÃC/C++дµÄDLLÄ£¿é£¬¶ÔPython½øÐй¦ÄÜÀ©Õ¹¡£ÕâÀïдһ¸ö¼òµ¥µÄÀý×Ó£¬Ö÷Òª¾ÍΪÁËÁ˽âÏÂÕâôÓÃPythonÀ´µ÷ÓÃC/C++дµÄDLL¿â¡£ºÃÁË£¬ÇÐÈëÕýÌ⣺
Ê×ÏÈ£¬ÎÒÊÇÓÃVS2003 ......
1.show status
Threads_connected µ±Ç°µÄÁ¬½ÓÊý
Connections ÊÔͼÁ¬½Óµ½(²»¹ÜÊÇ·ñ³É¹¦)MySQL·þÎñÆ÷µÄÁ¬½ÓÊý¡£
Max_used_connections ·þÎñÆ÷Æô¶¯ºóÒѾͬʱʹÓõÄÁ¬½ÓµÄ×î´óÊýÁ¿¡£
2.set GLOBAL max_connections=Á¬½ÓÊý;
flush privilege ......
±à¼my.cnfÎļþ£¬¼ÓÈ룺
log-slow-queries[=file] #ĬÈÏΪdataĿ¼ÏµÄhostname-slow.logÎļþ
long_query_time=10 (seconds) #Âý²éѯµÄthreshold
log-queries-not-using-indexes #¼Ç¼²»Ê¹ÓÃË÷ÒýµÄ²éѯ
mysqldumpslowÃüÁî»ñµÃÈÕÖ¾ÖÐÏÔʾµÄ²éѯժҪÀ´´¦ÀíÂý²éÑ¯È ......