How to use a simple SQLite queries?

Started by EK.IceFlake, Feb 22, 2015, 12:24 PM

Previous topic - Next topic

EK.IceFlake

Hi guys! My server is based on ini, which as you all know, caused lag. I want to found out how to use SQLite on VCMP, like creating tables, inserting into tables, updating tables, removing from tables, initialize database etc.
Thanks!!!

Fuzzie


EK.IceFlake

Quote from: Fuzzie on Feb 22, 2015, 12:33 PMFirst, you need to learn SQL (Structured Query Language)

W3Schools SQL Tutorial
Google Search
What about making it interact with vcmp, for example make a local variable test and set tests value to table player of where the player name is whatever. or know number of players...

Fuzzie

You can check out my Account script to see how I use the VC-MP 0.4 SQlite and mySQL functions.

EK.IceFlake

Quote from: Fuzzie on Feb 22, 2015, 01:16 PMYou can check out my Account script to see how I use the VC-MP 0.4 SQlite and mySQL functions.
How about making elements without tables (or just using table rowid 0/1)?

.

#5
Quote from: Fuzzie on Feb 22, 2015, 12:33 PMFirst, you need to learn SQL (Structured Query Language)

W3Schools SQL Tutorial
Google Search

And that's why this guy gave you those links and indications.

Quote from: NE.CrystalBlue on Feb 22, 2015, 04:46 PMHow about making elements without tables (or just using table rowid 0/1)?

Coz you have no idea what you're talking about. Or maybe I just don't understand your intentions.
.

Kratos_

#6
Quote from: NE.CrystalBlue on Feb 22, 2015, 01:10 PMWhat about making it interact with vcmp, for example make a local variable test and set tests value to table player of where the player name is whatever. or know number of players...

Making it interact with VC:MP?  The Sqlite plugin is doing its job of exporting the SQL functions. 
You just need to provide the instructions ( queries ) for manipulating the tables. For knowing
number of players ( rows) , use COUNT *.

Quote from: NE.CrystalBlue on Feb 22, 2015, 04:46 PMHow about making elements without tables (or just using table rowid 0/1)?

This looks hypothetical to me.  I mean if there are no tables then what your table manipulating
SQL queries supposed to be?
Where & to which are you going to perform your queries? Be more specific in your intentions.
In the middle of chaos , lies opportunity.

EK.IceFlake

Quote from: Kratos_ on Feb 23, 2015, 04:34 AM
Quote from: NE.CrystalBlue on Feb 22, 2015, 01:10 PMWhat about making it interact with vcmp, for example make a local variable test and set tests value to table player of where the player name is whatever. or know number of players...

Making it interact with VC:MP?  The Sqlite plugin is doing its job of exporting the SQL functions. 
You just need to provide the instructions ( queries ) for manipulating the tables. For knowing
number of players ( rows) , use COUNT *.

Quote from: NE.CrystalBlue on Feb 22, 2015, 04:46 PMHow about making elements without tables (or just using table rowid 0/1)?

This looks hypothetical to me.  I mean if there are no tables then what your table manipulating
SQL queries supposed to be?
Where & to which are you going to perform your queries? Be more specific in your intentions.
1. How do you set the variable to the count?
2. By that I mean, like I set the gravity to 200. Now restart the server. Now I could somehow find the gravity in that very table that I set it from, all without using [where gravity=0].
Thanks

.

Quote from: NE.CrystalBlue on Feb 23, 2015, 11:43 AM1. How do you set the variable to the count?
2. By that I mean, like I set the gravity to 200. Now restart the server. Now I could somehow find the gravity in that very table that I set it from, all without using [where gravity=0].
Thanks

Dude, just lock the topic because it's embarrassing. These guys clearly advised you to start from scratch and go learn what a database is and how to interact with it. And yet you keep asking more nonsense question because you still have no idea what you're talking about.

Do you really think someone here will teach you how to use SQL in one post? You must be dreaming if you think that. Sorry if I'm too harsh but it's getting ridiculous.
.

EK.IceFlake

Quote from: S.L.C on Feb 23, 2015, 11:51 AM
Quote from: NE.CrystalBlue on Feb 23, 2015, 11:43 AM1. How do you set the variable to the count?
2. By that I mean, like I set the gravity to 200. Now restart the server. Now I could somehow find the gravity in that very table that I set it from, all without using [where gravity=0].
Thanks

Dude, just lock the topic because it's embarrassing. These guys clearly advised you to start from scratch and go learn what a database is and how to interact with it. And yet you keep asking more nonsense question because you still have no idea what you're talking about.

Do you really think someone here will teach you how to use SQL in one post? You must be dreaming if you think that. Sorry if I'm too harsh but it's getting ridiculous.
BUT HOW TO GET SOME FUCKING VALUES TO A VARIABLE IN VCMP?

Fuzzie

You just want everything to be handed to you huh. I know SQL so believe when I say this. Learn SQL and you will find the answer yourself. The fact that you are asking question where the answers lie within the links I gave you just proves that you don't even try to put efforts into learning and searching for answers yourself. Also, being rude ain't gonna help you here.

.

#11
Quote from: NE.CrystalBlue on Feb 23, 2015, 11:56 AMBUT HOW TO GET SOME FUCKING VALUES TO A VARIABLE IN VCMP?

Extracted from that guys account system just because it's so "F*ING" easy when you know how to script:

/* Assuming we have the following table structure:

CREATE TABLE [my_table] (
[column_name] VARCHAR(32)  UNIQUE NOT NULL,
[column_value] NUMERIC DEFAULT '0' NULL
)

And assuming we have the following values:

INSERT INTO [my_table] ([column_name], [column_value]) VALUES ('world_gravity', 200);
*/


/* We run a query that targets the required data. In this case we want:
The value from column 'column_value'.
Located in the table named 'my_table'.
Where the value from the column 'column_name' matches 'world_gravity'.
*/
local result_handle = QuerySQL(database_handle, "SELECT [column_value] FROM [my_table] WHERE [column_name]='world_gravity'");

/*
Now we test if that query was successful.
*/

if (!result_handle) return false; // You failed!

/*
Now we extract the data from the returned query handle.
Actually it's not a query handle. That's a result handle but that doesn't matter.

Since the query only targeted one column with one value.
We extract the value at column 0.
*/

local world_gravity = GetSQLColumnData(result_handle, 0);

/*
Now that the value was extracted that would be a perfect time to free the memory used by the result handle.
*/

FreeSQLQuery(result_handle);

/*
Now print the extracted value to see if it worked.
*/

print("World gravity value was: " + world_gravity);

Would it hurt anyone if you would have asked that in the first place?
.

DizzasTeR

I'm still actually learning how to interact with database stuff, it really is annoying thing to learn ( my opinion ) but thanks to Fuzzie's account system i am really getting used to databases and at-least able to make my own things, I specially added his credits due to his great work in his v3 account system, you should really start looking at those links, just like I'm going to do and hopefully I will be good too when it comes to databases.