mysql-python mysqldb

http://mysql-python.sourceforge.net/

http://sourceforge.net/projects/mysql-python/

python 2.6 で 2.7は最新、3.xはこれからのようです。

インストール
pip-python install MySQL-python

Complete output from command python setup.py egg_info:
[localhost] out:     The required version of distribute (>=0.6.28) is not available,

こんなメッセージが出たので更新してから再度
easy_install -U distribute

Successfully installed MySQL-python
Cleaning up…

===
参考:fabric に設定して
fabric update_python_egg install_python_mysql -R all
で10数台1回で更新出来ます。

参考:fabric + cuisineで管理
Fabric, Cuisine and Watchdog for server administration in Python http://www.slideshare.net/ffunction/fabric-cuisine-and-watchdog-for-server-administration-in-python
===

使う。

http://mysql-python.sourceforge.net/MySQLdb.html

mysqlテスト
・接続

import _mysql

# 接続
 db = _mysql.connect( passwd=options.password, host=options.hostname, db=options.database, port=options.port, user=options.user, connect_timeout=3)
db.query( options.sql )
# クエリ
r = db.store_result()
#
data = r.fetch_row(0)
# 0で全件取得
print data
# ((‘5n’,), (‘h4′,), (‘hq’,), (‘pj’,), (‘sy’,), (‘wn’,))
# 数
count = r.num_rows()
print count
# 6
db.close()

optionsはoptionParsetを利用しています。

slaveのチェックは、データと
show slave statusを確認

# nagiosのスクリプトに入れました。

show table status from dbname;
でUpdate_timeとか見ようとしたらmyisamじゃないとnullだった。件数とサイズとか入れておく。

http://dev.mysql.com/doc/refman/5.5/en/show-table-status.html

This entry was posted on 金曜日, 2月 8th, 2013 at 4:44 PM and is filed under mysql, nagios, Python. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。