Starting with SQLite
#1

Hey guys. I've just started to switch my GM from Dini to SQLite. I have one question. I have enum with around 220 defines in it for user stats. Under OnGameModeInit I've added this:
pawn Код:
UserDatabase = db_open("Users.db");
    db_query(UserDatabase, "CREATE TABLE IF NOT EXISTS `USERS` (stats)");
Under stats after users, I need to write 220 names for fields that will be created inside of database, right?
Reply
#2

yea, u r ryt.
Reply
#3

Well, don't create all the 220 in 1 query, or I think pawncc will give some off parameters limit thing error. But it can be fixed using strcat.
Reply
#4

You should create those fields you need to save/load for a player. Not everything from the enum, I suppose some indexes are just for checking things in-game and they do not need to be saved.
Reply
#5

Quote:
Originally Posted by Sublime
Посмотреть сообщение
Well, don't create all the 220 in 1 query, or I think pawncc will give some off parameters limit thing error. But it can be fixed using strcat.
yea, it can be done with both ways.
Reply
#6

Thanks guys. I have no idea how big does my string need to be to store over 200 defines into it.
Код:
			 "pBanned", 
			 "Phnumber", 
			 "PhoneCredit", 
			 "AdMute", 
			 "JackSkill", 
			 "Death", 
			 "Kill", 
			 "X", 
			 "Y", 
			 "Z", 
			 "Int", 
			 "VW", 
			 "WalkStyle",
			 "Fac", 
			 "FacRank", 
			 "FacLeader", 
			 "FacDiv", 
			 "FacDivLeader", 
			 "Duty", 
			 "wSlot0", 
			 "wSlot1", 
			 "wSlot2", 
			 "wSlot3", 
			 "wSlot4", 
			 "wSlot5", 
			 "wSlot6", 
			 "wSlot7", 
			 "wSlot8", 
                         // and so on
Reply
#7

Just try using db_query and create 20 tables, and check if there is any errors. Increase the table creation by 10 when there isn't an error.
Reply
#8

Like I said before - you do not need everything from your enum. You're not supposed to save things that are not even needed and are just for in-game things.

For example, do you need to save the Duty? That's something related to in-game only and I assume many more indexes.

Don't worry about the query size, it's normal to use large queries for such as things. Anyways, you can even use Zeex's compiler patch that let the line be 4095 characters so you can be able to call strcat not so many times.

If you're interested: https://sampforum.blast.hk/showthread.php?tid=473595

But.. I'd recommend you to create the table manually from a SQLite Browser so you don't have to execute a query all the time about an already existed table!
Reply
#9

I wont save all of the indexes but I have to save most of them.
So manually would mean that I will just have to add fields to the database using Browser so I wont need to check each time the server starts if the table is created or not?
Reply
#10

That's right! The main key is not to execute a query everytime the server starts to check if the table exists and if not, to create it. It's kind of pointless, in my opinion.

Of course when I meant manually, I did not mean that you need to create each field and its type manually but execute a query through the 'Execute SQL' tab with CREATE TABLE clause.
Reply
#11

I will try to do something with the Browser. I've never worked in it before so I hope everything will be all right. Thanks Konstantinos.
EDIT: one more question. I found Execute Query in the browser, do I have to enter there same thing I would enter in pawno? I mean are the functions same for use in pawno and SQLite Database Browser?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)