João, No, SQLite transactions are not only ACID, the Isolation is Serializable, which means even if the execute concurrently, the result should be same as if they executed in series (on after the other). What @Anthony describes should not be necessary, since you already in a transaction.
https://www.sqlite.org/transactional.html https://www.sqlite.org/atomiccommit.html If everything is set up correctly, it should work. Please note that both sessions must be in a transaction to guarantee a consistent result. You can't just go change the database while the transaction is pending. That can fail. This is the purpose of transactions. Also please note that this is probably note the best way to do this. SQL has auto-increment fields that are good for assigning numbers to things, such as unique IDs to records. Web2py automatically creates an auto-increment ID field for all your tables. So if you have a table for Items, let's say, the ID field in that table will already be a unique number for every new record, which you could use for your serial number. Just insert a new record to get a new ID. If you don't want to use the built-in ID, you can create your own auto-increment field. If you have a table for Work Orders, it will already have an ID field that's automatically set to a new unique number for each record. Just insert a new record to get a new number. If you don't want to use the ID field as your work order number, you can create your own field. No need to read, update, and store counters. John On Thursday, March 21, 2019 at 3:18:20 PM UTC-7, João Matos wrote: > > @Leonel > Maybe I'm not explaining myself correctly. > > I tested and it isn't working the way I need and explained. > > My test was: > I put a sleep(10) between step 1 and 2. > On another session I changed the record in question. Checked the changed > was done. > Waited for the sleep to end and then step 2 wrote over the change I made > on the other session. > The end result is that the transaction isn't protecting (locking) the > records in question, which is what I need. > > > quinta-feira, 21 de Março de 2019 às 13:11:27 UTC, Leonel Câmara escreveu: >> >> The transaction is atomic, that means there's nothing happening in the >> middle. Your use case is fine. Of course, that if you give the user a form, >> while he's editing it, the form can be changed by others as well, in that >> case you need to add your own locking or check the record for modifications >> while the user was editing the form. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.