[Help] SQLite
#1

Hello there, I am creating a system to save vehicles in the server, I am using DB as SQLite, together with the SQLite DB Browser to create and configure.

I'm new, I'm still learning the functionality of this DB, most of the tutorials are not in my native language.

So ... I created a command to see if the table is updated, but simply nothing happens.

CMD:
PHP Code:
ACMD:instab[1](playeridparams[])
{
    new 
Query[250];
    new 
result;
    
format(Querysizeof(Query), "INSERT INTO `Veнculos` (`VOwner`) VALUES ('%s')"PlayerName(playerid)); 
    
db_query(pCarsQuery);
    
SendClientMessage(playeridDebugColor"Done");
    return 
1;

And i have this other things
PHP Code:

new DB:pCars;
public 
OnGameModeInit()
{
    
pCars db_open("pCars.db");
}
public 
OnGameModeExit()
{
    
db_close(pCars);

Someone can help me?
Reply
#2

Enable sqlite db logging (https://sampwiki.blast.hk/wiki/Server.cfg#Logging) and see your server log for errors.
Reply
#3

Use db_free_results(db_query(...)); Since the query results are stored in the memory and can cause memory leak.

And you need to make the tables at first - whether you run queries or make them in the database yourself. But without existence of tables, you can't insert something in that table.
Reply
#4

Try changing your table name to something in english, also db tables are case sensitive on linux just fyi
Reply
#5

Ok i change to this:
PHP Code:
ACMD:instab[1](playeridparams[])
{
    new 
Query[250];
    new 
result;
    
format(Querysizeof(Query), "INSERT INTO `Veh` (`VOwner`) VALUES ('%s')"PlayerName(playerid)); 
    
db_query(pCarsQuery);
    
SendClientMessage(playeridDebugColor"Feito");
    
db_free_results(db_query(pCarsQuery));
    return 
1;

But, the compiler gave this error: "error 017: undefined symbol "db_free_results"
On this line:
PHP Code:
    db_free_results(db_query(pCarsQuery)); 
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=449536

And it's db_free_result, I believe. Use the samp wiki.
Reply
#7

Quote:
Originally Posted by Logic_
View Post
Use db_free_results(db_query(...)); Since the query results are stored in the memory and can cause memory leak.

And you need to make the tables at first - whether you run queries or make them in the database yourself. But without existence of tables, you can't insert something in that table.
There's no need to use db_free_result unless there is some result.He's performing Insertion and no result is being stored in the memory.

@OP: As RoboN1X said enable db logging and check the server log to see what's going wrong.
Reply
#8

Quote:
Originally Posted by GhostHacker9
View Post
There's no need to use db_free_result unless there is some result.He's performing Insertion and no result is being stored in the memory.

@OP: As RoboN1X said enable db logging and check the server log to see what's going wrong.
Hey buddy bud bud,

https://sampwiki.blast.hk/wiki/Db_query

According to the wiki - the return type has been changed since 0.3.7 R2 and it has been put in the important note as well to clear the query results.

All what I'm conveying is what I know.

x.
Reply
#9

I put the db logging but nothing appears when I give the command, I put "db_logging 0" in server.cfg, but nothing.
Reply
#10

Quote:
Originally Posted by ApolloScripter
View Post
I put the db logging but nothing appears when I give the command, I put "db_logging 0" in server.cfg, but nothing.
db_logging set it to 1 in order for it to work on the server command console

useful SQLite on server.cfg

logqueries - is a boolean variable in the server console it enables to log all information based on players SQLite features.

db_logging - in enables the server console to print error informations if something went wrong

db_log_queries - it enables to call from the include queries strings

and dont forget if you want to free results its only done when you select statements are in use in order to free the SQLite results
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)