0
この質問が初心者の場合は、私はSQL Alchemyを初めて使います。私はすでに発生したデータベース内のイベントを削除しようとしています。私のスクリプトは以下の通りです。 **と行でSQL Alchemy:AttributeError:型オブジェクト 'events'には 'query'属性がありません
、私はエラー
AttributeError: type object 'events' has no attribute 'query'
は、この問題を解決する方法を誰もが知っているのですか?ありがとう!
Base = automap_base()
# engine, suppose it has two tables 'user' and 'address' set up
engine = create_engine("DB_URL")
# reflect the tables
Base.prepare(engine, reflect=True)
# mapped classes are now created with names by default
# matching that of the table name.
Event = Base.classes.events
User = Base.classes.users
**events = Event.query.filter(end_time < datetime.now())**
session = Session(engine)
session.delete(events)
session.commit()
あなたのコード。 'session.query(Event).filter(Event.end_time
alpaca
乾杯、これを反映するために私の答えを編集するかもしれません。私はあなたが選択オブジェクトに対して 'delete'を呼び出す必要があるのを忘れていました。 –