python Mysql驅動包測試_bug修改

    今天潛心研究了python 的Mysql驅動包,主要是對Python頗有感受.python

下載wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.5.zipmysql

     解壓、編譯、安裝一下,而後開始測試驅動包裏給的示例文件:linux

[root@localhost examples]# pwdsql

/home/xuegang/mysql-connector-python-1.0.5/python2/examplescentos

[root@localhost examples]# 數據結構

[root@localhost examples]# 測試

[root@localhost examples]# ll.net

total 44code

-rw-r--r--. 1 root root 4214 Aug 23 23:37 client.pyorm

-rw-r--r--. 1 root root 1829 Jul 17 20:51 config.py

-rw-r--r--. 1 root root 3519 Jul 17 20:51 dates.py

-rwxr-xr-x. 1 root root 1840 Jul 17 20:51 engines.py

-rw-r--r--. 1 root root    0 Jul 17 20:51 __init__.py

-rwxr-xr-x. 1 root root 2772 Jul 17 20:51 inserts.py

-rw-r--r--. 1 root root 3324 Jul 17 20:51 microseconds.py

-rw-r--r--. 1 root root 2997 Jul 17 20:51 multi_resultsets.py

-rwxr-xr-x. 1 root root 3883 Jul 17 20:51 transaction.py

-rwxr-xr-x. 1 root root 2921 Jul 17 20:51 unicode.py

-rwxr-xr-x. 1 root root 2036 Jul 17 20:51 warnings.py

[root@localhost examples]# python client.py 

Welcome to MySQL Python CLI.

Server version: 5.1.61

MySQL Connector/Python vpython.2.6

 

Python 2.6.6 (r266:84292, Dec  7 2011, 20:48:22) 

[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

(MySQLConsole)

>>> show databases;

(u'information_schema',)

(u'mysql',)

(u'test',)

>>> 

用起來倒像Mysql-client, 不過表示爲Python 格式的數據結構。

client.py 這個文件,在centos6.2 上安裝默認的mysql,其中有部分代碼仍是須要修改下:

130     console = MySQLConsole(db)

131     #myconnpy_version = "%s-%s" % (

132     #    '.'.join(map(str,mysql.connector.__version__[0:3])),

133     #    mysql.connector.__version__[3])

135     myconnpy_version = 'python.2.6'

136     #print "Your MySQL connection ID is %d." % (db.get_server_threadid())

註釋掉這些行直接就可使用了,這估計也是Python 靈活性的代價吧。

而後怎樣使用,直接練習example文件夾裏的文件..

相關文章
相關標籤/搜索