Archive for 7月, 2009

mysql:テーブルのrepair

mysqlでこんなエラーメッセージが出てた。

Table table_name is marked as crashed and should be repaired

とりあえず、エラーが出ているテーブルを調べる。

mysql> check table table_name;
+----+---+----+-------------------+
| Table | Op | Msg_type | Msg_text |
+----+---+----+-------------------+
| table_name | check | warning | Table is marked as crashed |
| table_name | check | warning | 1 client is using or hasn’t closed the table properly |
| table_name | check | error | Record at pos: 482160 is not remove-marked |
| table_name | check | error | record delete-link-chain corrupted |
| table_name | check | error | Corrupt |
+----+---+----+-------------------+

確かにテーブルにエラーがある。
これを直すにはrepairコマンドを使うらしい。
mysql> repair table table_name;
+----+----+----+--------------+
| Table | Op | Msg_type | Msg_text |
+----+----+----+--------------+
| table_name | repair | warning | Number of rows changed from 63 to 64 |
| table_name | repair | status | OK |
+----+----+----+--------------+
これで直ったっぽい。
どうしてこの手順で直るのかはいつか調べる。

vim:pythonの構文チェック

pythonの文法チェックをエディタ上で行いたい場合のvimの設定方法。

用意するもの
pylint (http://www.logilab.org/857)
logilab-astng (http://www.logilab.org/856)
logilab-common (http://www.logilab.org/848)

インストール
 上記の3つをpython setup.pyでインストール

python setup.py install

_gvimrcに記述を追加

” ファイルタイププラグインを有効にする
:filetype plugin on
ftplugin/python.vimに記述を追加
nelnal@pythonさんからコピーさせていただきました)
※%を”で囲わないとスペースを含むファイルパスを正しく処理できないのでそこだけ変更
command! Python call s:Python()
nmap :Python

function! s:Python()
:w
:!python “%”
endfunction

command! PyChecker call s:PyChecker()
nmap :PyChecker

function! s:PyChecker()
:w
:!pyChecker “%”
endfunction

F5キーでpythonスクリプトを実行
F4キーでpycheckerを使った構文チェックを行います。