Creation/Dev/Gscript/Using SQLite: Difference between revisions
((sorry for the spam; computer keeps BSoDing, saving every so often to be safe)) |
|||
Line 14: | Line 14: | ||
== Why use SQLite? == | == Why use SQLite? == | ||
There are advantages and disadvantages to using SQLite for storing data. Like any data storage method, there are times where it is practical to use it, and times when it isn't so practical. | There are advantages and disadvantages to using SQLite for storing data. Like any data storage method, there are times where it is practical to use it, and times when it isn't so practical. | ||
The main advantage to using SQLite is that all of your data is stored in a central location. This allows you to compare the data quickly and easily, without a lot of extra code. | |||
This isn't going to make a lot of sense until later, but let's pretend I have a table with two columns: "account" and "hours". If I wanted to figure out which players have more than 5 hours and less then 10, I can simply run a query like this: | |||
SELECT * FROM players WHERE hours > 5 | |||
Using traditional storage methods, such as [http://en.wikipedia.org/wiki/Flat_file_database flatfile], the file might look something like this: | |||
Stefan=10 | |||
unixmad=3 | |||
(npcserver)=6 |
Revision as of 18:31, 5 December 2009
Preamble
Target Audience
This guide will not teach you how to script. It is directed toward already-competent scripters who wish to incorporate SQLite into their scripts.
Required Skills and Knowledge
- Basic understanding of GS2
- Basic understanding of storing data in traditional ways (flatfile)
- Basic understanding of the way tables work (for example, Microsoft Excel)
Introduction
What is SQLite?
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
In English, it is a script that stores data into tables, the way any SQL language works (e.g. MySQL).
Why use SQLite?
There are advantages and disadvantages to using SQLite for storing data. Like any data storage method, there are times where it is practical to use it, and times when it isn't so practical.
The main advantage to using SQLite is that all of your data is stored in a central location. This allows you to compare the data quickly and easily, without a lot of extra code.
This isn't going to make a lot of sense until later, but let's pretend I have a table with two columns: "account" and "hours". If I wanted to figure out which players have more than 5 hours and less then 10, I can simply run a query like this:
SELECT * FROM players WHERE hours > 5
Using traditional storage methods, such as flatfile, the file might look something like this:
Stefan=10 unixmad=3 (npcserver)=6