Raised This Month: $51 Target: $400
 12% 

SQLite local database


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-14-2014 , 18:03   SQLite local database
Reply With Quote #1

How to make SQLite local database? I searched but didn't find any tuts :/
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-14-2014 , 18:22   Re: SQLite local database
Reply With Quote #2

SQL_SetAffinity("sqlite");
SQL_MakeDbTuple("localhost", "root", "", "database");
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-14-2014 , 18:35   Re: SQLite local database
Reply With Quote #3

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/
__________________
Impossible is Nothing
Sylwester is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-15-2014 , 03:17   Re: SQLite local database
Reply With Quote #4

Quote:
Originally Posted by YamiKaitou View Post
SQL_SetAffinity("sqlite");
SQL_MakeDbTuple("localhost", "root", "", "database");
Quote:
Originally Posted by Sylwester View Post
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?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 10-15-2014 at 03:19.
GuskiS is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-15-2014 , 06:35   Re: SQLite local database
Reply With Quote #5

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.
__________________
Impossible is Nothing
Sylwester is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-15-2014 , 07:56   Re: SQLite local database
Reply With Quote #6

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
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-15-2014 , 09:35   Re: SQLite local database
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
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.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 10-15-2014 at 09:36.
GuskiS is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-15-2014 , 09:48   Re: SQLite local database
Reply With Quote #8

You could, but why make calls to natives that you don't need?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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