SQLAlchemyメモ
毎回ググるので、メモっておく。 このブログがSEOされて、このエントリが上位に来れば、次ググる時楽になる寸法だ!
INSERT IGNORE INTO ...
insert(..., prefixes=['IGNORE'])
SELECT ... FOR UPDATE
select(..., for_update=True)
随時更新したい。
written by shn, on Aug 5, 2009 1:49:00 PM.
毎回ググるので、メモっておく。 このブログがSEOされて、このエントリが上位に来れば、次ググる時楽になる寸法だ!
insert(..., prefixes=['IGNORE'])
select(..., for_update=True)
随時更新したい。
Categories: メモ | Tagged as: Python, SQLAlchemy | 0 comments
written by shn, on Apr 13, 2009 12:31:00 PM.
自己参照型のrelationを作ろうとしていて、子供を追加しても「循環参照だ!」って怒られてプチ困った。 マニュアル読んだら答かいてあったよメモ
以下、Adjacency List Relationships - Mapper Configuration からコピペ
親 > 子は普通で良い
mapper(Node, nodes, properties={
'children': relation(Node)
})
子 > 親はremote_sideという引数にカラムを指定する
mapper(Node, nodes, properties={
'children': relation(Node, backref=backref('parent', remote_side=[nodes.c.id]))
})
remote_sideは
used for self-referential relationships, indicates the column or list of columns that form the "remote side" of the relationship.
とのこと。これ以上はコードを追ってないので、なんでこうしないと普通の1:Nとして関係が作れないかはわからず…
Categories: メモ | Tagged as: Python | 2 comments
written by shn, on Apr 6, 2009 11:19:00 PM.
海外だと、Anonymous Subscriber ID (ASID)って言うのかね?
iPhone SDK: Retrieving MSISDN or SIM ID for Authentication (iPhone forum at JavaRanch)
NSString *uniqueID = [[UIDevice currentDevice] uniqueIdentifier]
あとで読む
ASID Mobile WebSite Developers Cookbook
日本のは
Categories: メモ | Tagged as: iPhone | 0 comments
written by shn, on Mar 29, 2009 7:58:00 PM.
WINVER的な奴が欲しい。とりあえず、これで良さげ。
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_2_2
Categories: メモ | Tagged as: iPhone | 0 comments
written by shn, on Mar 15, 2009 2:54:00 AM.
iPhoneの素晴しいところの一つは、Crash Logが本体に保存される事なんですが、
Thread 0 Crashed:
0 libobjc.A.dylib 0x300c8c18 objc_msgSend + 20
1 Fastweet2k 0x00016240 0x1000 + 86592
2 UIKit 0x30b2b414 -[UITextView keyboardInputChanged:] + 80
3 UIKit 0x30bcaf1c -[UIWebDocumentView keyboardInputChanged:] + 40
このように、デバッグバイナリでもシンボルが出ないときがあります。 symolicatecrashを使ってもだめでがっかり。
でも、dSYMがあるから頑張ればなんとかなるんじゃね?とやってみたらなんとかなった。 普段VisualStudioの微温湯に浸かっている僕には大変でした。
% gdb --quiet Fastweet2k.app.dSYM/Contents/Resources/DWARF/Fastweet2k
(gdb) info line *0x16240
Line 179 of "/Users/shn/Documents/projects/git/fastweet/Classes/TweetViewController.m" starts at address 0x16212 <-[TweetViewController sendPressed:]+118> and ends at 0x162e4 <-[TweetViewController sendPressed:]+328>.
てな感じ。
上記のCrash Logはdebug版バイナリのものだったので、_./build/Debug-iphoneos/_にあるdSYMをgdbで開き、info lineコマンドで、対応するソースコードの位置が出てきます。
しかし、出てきたのは良いが何故ここでハングアップするのか、というか何故あの操作でこの関数が呼ばれるのか不明で泣きそう。
ついでに、symbolicatecrashの解説はここが詳しいです。
Categories: メモ | Tagged as: iPhone | 0 comments
written by shn, on Feb 24, 2009 6:28:00 PM.
Python(2.6@win32)を起動するだけなら、以下のlibがあれば良いようだ
site
os
ntpath (win32)
stat
genericpath
warning
linecache
types
UserDict(win32)
_abcoll
abc
copy_reg
encodings
codecs
site.pyはいじって、site-packages等を読み込まないようにしている。
sys.setdefaultencoding('utf-8')とかしないなら、encodings以下もいらないのかな。codings:utf-8なんてスクリプトが読めなくなるかな。
_zipimportは組込みなので、上記パッケージはzipできる。zipすると57KBととてもスッキリ
Categories: メモ | Tagged as: Python | 0 comments
written by shn, on Feb 23, 2009 6:20:00 PM.
多分これと一緒。 Boost.Pythonをpython-debuggingにしてビルドしたものを使うと、Pythonの関数を呼んだ時に逝くという問題。 環境は恐らくWindowsのみで、うちの場合はboost 1.38.0, MSVC 9, Python 2.6。
原因はpython-debugging=onにしてできる、boost_python-vc90-mt-gy-1_38.dllがPython26.dllと、Python26_d.dllの両方にリンクしてるからっぽい。
深く追うのがめんどくさかったので、tools\build\v2\tools\python.jam L:102に、condition = <python-debugging>on ;を挿入して無理矢理解決。
ざっと見た感じ、tools\build\v2\build\toolset.jam L:32でinitを空で呼んでいるせいで、
python.jamのinitに$(condition)が渡されてないのかなぁ、と。
bjamの引数に-d 7とか渡すとbjam内の引数と関数呼び出しを全部出力できて便利。
(ref: bjam usage)
Categories: メモ | Tagged as: Boost, Python | 0 comments
Proudly powered by Zine.