Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ sqlite3 db open/close question

sqlite3 db open/close question

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Renny   Canada  (26 posts)  Bio
Date Sun 23 Nov 2014 03:38 PM (UTC)

Amended on Sun 23 Nov 2014 04:18 PM (UTC) by Renny

Message
I am going by the documentation (http://www.gammon.com.au/scripts/doc.php?general=lua_sqlite3) and opening my db -> execute/query -> closing the database.

I do a lot of queries constantly so I am wondering if I should just be opening the database on plugin connect and then closing it on disconnect, instead of opening and closing thousands of times in a session.

Are there risks to not closing it? Does opening/closing so many times cause noticeable lag compared to just opening it once?

Any input appreciated.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 23 Nov 2014 07:51 PM (UTC)
Message
You should certainly only open and close it once per session.

There is a considerable overhead in opening a file.

As for risks, SQLite3 is specifically designed to cope with crashes. It has a rollback mechanism which restores any partially done transaction.

If you want to be extra safe, backup (make a copy) of the database file every day or so. Do this when the file is closed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,136 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.