SQLite database related question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SQLite database related question (
/showthread.php?tid=185056)
SQLite database related question -
Miguel - 23.10.2010
What should I do, open the database on the server start and close it on the server exit or open it only when I'm making a query?
This:
pawn Код:
public OnGameModeInit()
{
db_open("mydatabase.sqlite");
return 1;
}
public OnGameModeExit()
{
db_close(db_var);
return 1;
}
Or this:
pawn Код:
public OnPlayerConnect()
{
db_open("name.sqlite");
// query and code
db_close(db_var);
return 1;
}
Re: SQLite database related question -
Calgon - 23.10.2010
Keep the connection alive, don't kill it every time that you use OnPlayerConnect. I'm 99% positive that re-opening it and closing it every time that OnPlayerConnect is called would be the inefficient way, resulting in the rest of your OnPlayerConnect code being executed a lot slower.
Anyhow, kudos on using SQLite.
Re: SQLite database related question -
Miguel - 23.10.2010
Alright, thanks for sharing your opinion.