lunarmodules / luasql

LuaSQL is a simple interface from Lua to a DBMS.
http://lunarmodules.github.io/luasql
547 stars 192 forks source link

When do transactions end? #134

Closed eko234 closed 2 years ago

eko234 commented 2 years ago

Hi, I wanted to know if I can manually handle transactions, I mean, I want to know if I can run multiple queries under the same transaction, and how do I know what or where is the transaction? I come from libraries that explicitly allow me to get a connection that automatically handles transactions and getting transactions themselves as connections to use them as I need.

Sorry if I have worded it wrong.

tomasguisasola commented 2 years ago

Technically, your question is related to the database/driver, not to LuaSQL, which is just a thin layer between Lua and the DBMS. You should check the API of each driver to see if it provides what you have in mind.

In general, you have to turn off autocommit to "start" a transaction. Then use commit or rollback to end it (and automatically start a new one).

eko234 commented 2 years ago

Oh thanks, I understand now