AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLite local database (https://forums.alliedmods.net/showthread.php?t=249925)

GuskiS 10-14-2014 18:03

SQLite local database
 
How to make SQLite local database? I searched but didn't find any tuts :/

YamiKaitou 10-14-2014 18:22

Re: SQLite local database
 
SQL_SetAffinity("sqlite");
SQL_MakeDbTuple("localhost", "root", "", "database");

Sylwester 10-14-2014 18:35

Re: SQLite local database
 
You need to make sure that sqlite module is running (you can start it from plugin with #pragma loadlib sqlite).
If mysql module is running too then you have to use SQL_SetAffinity("sqlite") before making tuple.
Make tuple using: g_sql_tuple = SQL_MakeDbTuple("", "", "", "filename")
Your database will be saved in addons\amxmodx\data\sqlite3\filename.sq3
You can then view and edit your database using other tools like http://sourceforge.net/projects/sqlitebrowser/

GuskiS 10-15-2014 03:17

Re: SQLite local database
 
Quote:

Originally Posted by YamiKaitou (Post 2211139)
SQL_SetAffinity("sqlite");
SQL_MakeDbTuple("localhost", "root", "", "database");

Quote:

Originally Posted by Sylwester (Post 2211143)
You need to make sure that sqlite module is running (you can start it from plugin with #pragma loadlib sqlite).
If mysql module is running too then you have to use SQL_SetAffinity("sqlite") before making tuple.
Make tuple using: g_sql_tuple = SQL_MakeDbTuple("", "", "", "filename")
Your database will be saved in addons\amxmodx\data\sqlite3\filename.sq3
You can then view and edit your database using other tools like http://sourceforge.net/projects/sqlitebrowser/

Thanks for reply, nicely done :)
But which tuple type is the right one - with or without (you hihi) login data?

EDIT: Does anything else changes from MySQL? Or everything remains the same?

Sylwester 10-15-2014 06:35

Re: SQLite local database
 
From my experience I can say that login data does not matter when using sqlite, but still most of my plugins use similar code to what YamiKaitou posted ("127.0.0.1", "root", "", ...).

Some mysql queries may not work with sqlite, but if you design them properly you can make them work with both.

YamiKaitou 10-15-2014 07:56

Re: SQLite local database
 
SQLite (for AMXX) does not have login credentials, so any that you pass will be ignored. I only include it for my benefit and readability

GuskiS 10-15-2014 09:35

Re: SQLite local database
 
Quote:

Originally Posted by YamiKaitou (Post 2211310)
SQLite (for AMXX) does not have login credentials, so any that you pass will be ignored. I only include it for my benefit and readability

So, basicly I could use the same as for MySQL DB (from those amx_sql cvars)? If so, with preprocessor/cvar for Affinity I could make it support mysql or sql, right?

Anyways, thanks guys, much appreciated.

YamiKaitou 10-15-2014 09:48

Re: SQLite local database
 
You could, but why make calls to natives that you don't need?


All times are GMT -4. The time now is 17:37.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.