On Tuesday, February 21, 2017 at 4:38:07 AM UTC-8, Roger Oberholtzer wrote: > > I would like to update some information in trac.db. Specifically, > information in a table called 'download'. I have no trouble generating > the update commands. It is more that I want to be certain nothing goes > wrong. >
Make sure to use trac-admin hotcopy to make a backup before starting. > trac.db does not exist on the machine that I would like to have run > the update script (not written in python). I have the file system with > the db mounted on that Linux machine via nfs. The server running Trac > is also Linux. > > My script opens the db, reads the download table, and possibly updates > records in that table. > > What I am a bit worried about is concurrency. trac is also running, > and so has the db open. I cannot be certain that someone might do > something at the same time that also updates the download table (like > downloading a file). > It sounds like you should not attempt to write to the database from multiple connections: http://stackoverflow.com/a/376606/121694 > What is the best way to do this sort of thing? I want the update to > happen as the result of some activity outside of trac, > You could shutdown Trac or set it read-only while your script runs. If you don't want to do that, and your script needs to run periodically, you should probably consider running your script on the same machine that Trac is running. You could still trigger the execution of that script in response to some external action. If you write a script that opens the Environment and use the Trac database API to write to the database, your script would then be using the same database connection as Trac. from trac. env import Environment env = Environment(/path/to/environment) with env.db_transaction as db: ... # do inserts/updates/deletes If it's still not clear what's a good solution, I might be able to give better advice if you provide a few more details about what you are trying to accomplish with the script. - Ryan -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.
