my app needs save changes whilst offline , upload them when reconnects.
i know use sqlite, json, ect save them if sqlalchemy commit memory instead cut down code. not concerned powerloss or program crashes atm.
i assumed using sessions.add() , when reconnected sessions.commit() commit changes, seems overwritten when add another.
is possible this?
you can use sqlite in-memory database:
engine = create_engine('sqlite://')
take @ autoflush
setting:
when true, query operations issue flush() call session before proceeding. convenience feature flush() need not called repeatedly in order database queries retrieve results. it’s typical autoflush used in conjunction autocommit=false. in scenario, explicit calls flush() needed; need call commit() (which flushes) finalize changes.
it may working against you, add
states that:
place object in session.
state persisted database on next flush operation.
repeated calls add() ignored. opposite of add() expunge().
other popular options short-term data storage include redis.