I have a SQLAlchemy-based tool for selectively copying data between two different databases for testing purposes. I use the merge()
function to take model objects from one session and store them in another session. I'd like to be able to store the source objects in some intermediate form and then merge()
them at some later point in time.
It seems like there are a few options to accomplish this:
DELETE
/ INSERT
SQL statements. Seems pretty straightforward, I think I can get SQLAlchemy to give me the INSERT
statements, and maybe even the DELETE
s. Has anyone tackled this problem before? If so, what was your solution?
EDIT: I found a tool built on top of SQLAlchemy called dataset that provides the freeze functionality I'm looking for, but there seems to be no corresponding thaw functionality for restoring the data.
I haven't used it before, but the dogpile caching techniques described in the documentation might be what you want. This allows you to query to and from a cache using the SQLAlchemy API:
http://docs.sqlalchemy.org/en/rel_0_9/orm/examples.html#module-examples.dogpile_caching
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.