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

sqlite in sqlx...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodeStepper
Member
Join Date: Jun 2013
Location: Polska
Old 07-11-2013 , 19:02   sqlite in sqlx...
Reply With Quote #1

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... 

Last edited by CodeStepper; 07-12-2013 at 02:43.
CodeStepper is offline
CodeStepper
Member
Join Date: Jun 2013
Location: Polska
Old 07-12-2013 , 03:59   Re: sqlite in sqlx...
Reply With Quote #2

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!!

Last edited by CodeStepper; 07-12-2013 at 04:00.
CodeStepper is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 07-12-2013 , 04:48   Re: sqlite in sqlx...
Reply With Quote #3

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

Last edited by Clauu; 07-12-2013 at 04:48.
Clauu is offline
CodeStepper
Member
Join Date: Jun 2013
Location: Polska
Old 07-12-2013 , 06:38   Re: sqlite in sqlx...
Reply With Quote #4

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?

Last edited by CodeStepper; 07-12-2013 at 06:53.
CodeStepper is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 07-12-2013 , 07:42   Re: sqlite in sqlx...
Reply With Quote #5

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().
__________________
Impossible is Nothing
Sylwester is offline
CodeStepper
Member
Join Date: Jun 2013
Location: Polska
Old 07-12-2013 , 10:24   Re: sqlite in sqlx...
Reply With Quote #6

Thank you for answer, now I know how it works

Last edited by CodeStepper; 07-12-2013 at 10:24.
CodeStepper 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 17:15.


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