AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   sqlite in sqlx... (https://forums.alliedmods.net/showthread.php?t=220552)

CodeStepper 07-11-2013 19:02

sqlite in sqlx...
 
Ok...
Hi :)

So... i try to create a sqlite database in my local server. So... this is my code:


PHP Code:

out_void public xt_database_initin_char dbname[] )
{
    
var_char dbnoext[20] = EMPTY;
    
    
substrdbnamedbnoext0strposdbname'.' ) );

    
SQL_SetAffinity"sqlite" );
    
gg_databasehandle SQL_MakeDbTuple""""""dbnoext );
    
    
SQL_ThreadQuerygg_databasehandle"xt_database_check_query",
    
"CREATE TABLE IF NOT EXISTS server_options\
    (\
        id INT NOT NULL PRIMARY KEY,\
        value INT NOT NULL\
    )" 
);


And... it flush me error:
Code:

L 07/12/2013 - 00:53:40: [myplugin.amxx] 2003 : Can't connect to MySQL server on 'localhost' (10061)
What's wrong? Why is it trying to connect to mysql server not sqlite?

PS: I forgot to add this...
PHP Code:

#define var_char new
#define out_void
#define in_char

And... substr and strpos definition... 


CodeStepper 07-12-2013 03:59

Re: sqlite in sqlx...
 
Ok... i solve the problem. I write it... maybe it will be usefull for other people...

In one word... DAFUQ is this!
In sqlx.inc ( cstrike/addons/amxmodx/scripting/include ), this lines load a mysql_amxx library, not sqlite_amxx
PHP Code:

#if AMXX_VERSION_NUM >= 175
 #pragma reqclass sqlx
 #if !defined AMXMODX_NOAUTOLOAD
  #pragma defclasslib sqlx mysql
 #endif //!defined AMXMODX_NOAUTOLOAD
#endif //AMXX_VERSION_NUM 

Just change it on this:

PHP Code:

#if AMXX_VERSION_NUM >= 175
 #pragma reqclass sqlx
 #if !defined AMXMODX_NOAUTOLOAD
  #pragma defclasslib sqlx sqlite
 #endif //!defined AMXMODX_NOAUTOLOAD
#endif //AMXX_VERSION_NUM 

And it will be working... I have no idea for what is SQL_SetAffinity, but this function doesn't work!!

Clauu 07-12-2013 04:48

Re: sqlite in sqlx...
 
You have to enable manually sqlite/mysql in modules.ini and then make some checks to see if the right module is loaded and call SQL_SetAffinity if SQL_GetAffinity does not returns what you want. Also after SQL_MakeDbTuple you should initiate the connection with SQL_Connect

CodeStepper 07-12-2013 06:38

Re: sqlite in sqlx...
 
Oh... it works too... Thanks :)

But... in SQL_ThreadQuery must I type handle from SQL_MakeDbTuple or from SQL_Connect?

PS: Ok, I checked - from MakeDbTuple... so, for what I must use SQL_Connect?

Sylwester 07-12-2013 07:42

Re: sqlite in sqlx...
 
SQL_Connect returns connection handle. You would only need it for SQL_QuoteString or if you need to send non-threaded queries in plugin_end() or plugin_init().

CodeStepper 07-12-2013 10:24

Re: sqlite in sqlx...
 
Thank you for answer, now I know how it works :)


All times are GMT -4. The time now is 06:22.

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