1
私はSQLAlchemyを初めて使用しました。私は明らかに何かをやっている私はSQLAlchemy:event.listens.for()の作業を行うことができません
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, ForeignKey
from sqlalchemy import Integer, UnicodeText
from sqlalchemy import event
#variables feching is hidden
db = create_engine("mysql://"+dbLogin+":"+dbPassword+"@"+dbAddress+"/"+dbDatabase)
metadata = MetaData(db)
#the log table is not explicitly defined but rather uses the autoload function
logtable = Table('logs', metadata, autoload=True)
#and here I am trying to start "processLogChanged" after_insert on the "logs" table
@event.listens_for(logtable, "after_insert")
def processLogChanged():
print "---- the log table has changed"
を参照しています私はいくつかのデータが挿入された後にメソッドを実行するために探していますが、私は、オブジェクトに関連するタイプのいくつかのエラー「属性[...]」に走り続けます間違った私は、その場合には、あなたが私の手ここ
を与えることができれば、それは素晴らしいことだ、インスタンスのスタックをされる質問/回答の多くを通じて精練されており、ここでは、右を見つけることができません
Traceback (most recent call last):
File "optra.py", line 144, in <module>@event.listens_for(logtable, "after_insert")
File "/home/jpp/anaconda2/lib/python2.7/site-packages/sqlalchemy/event/api.py", line 124, in decorate
listen(target, identifier, fn, *args, **kw)
File "/home/jpp/anaconda2/lib/python2.7/site-packages/sqlalchemy/event/api.py", line 89, in listen
_event_key(target, identifier, fn).listen(*args, **kw)
File "/home/jpp/anaconda2/lib/python2.7/site-packages/sqlalchemy/event/registry.py", line 194, in listen
dispatch_collection = getattr(target.dispatch, identifier)
File "/home/jpp/anaconda2/lib/python2.7/site-packages/sqlalchemy/event/base.py", line 95, in __getattr__
raise AttributeError(name)
AttributeError: after_insert
ありがとうございました