SQLiter Tutorial

BlitzMax Forums/BlitzMax Tutorials/SQLiter Tutorial

René(Posted 2006) [#1]
SQLiter is an even more easier way to operate with SQLite databases. If you are afraid of pointers and callback functions in function calls then this one is for you. All the 'ugly' is stuff is made by SQLiter.

SQLiter Tutorial


I also recomend Assari's SQLite tutorial. It's very good and will give you good information about the bare bones.


Booticus(Posted 2006) [#2]
René!!! THANKS for this awesome tutorial and mod!!! You and Teamonkey have made my life way easier now!


René(Posted 2006) [#3]
Your very welcome.


Booticus(Posted 2006) [#4]
Hey I have a question. Is it possible to enummerate all the column names of a table? I'm trying to create a copy of a table, and I want to cycle through all column names of the existing table, and manually create another table with the same column names.

The MySQL Copy table function:

CREATE TABLE new_table SELECT * FROM old_table;

would be perfect, but it seems SQLite doesn't have the equivalent.

Thanks for any help!


assari(Posted 2006) [#5]
There's an example in this tutorial on how to cycle thru the columns. See how the Callback function prints out all the column names.


Booticus(Posted 2006) [#6]
Thanks Assari!


Booticus(Posted 2006) [#7]
Ooops! I meant in SQLiter! I havent messed with the raw SQLite stuff. :)

"If you are afraid of pointers and callback functions in function calls then this one is for you. All the 'ugly' is stuff is made by SQLiter."

I am afraid of callbacks! Hehehehe!


assari(Posted 2006) [#8]
Booticus, give it a go. If you go thru the tutorial starting from Part 1, you'll be surprised how easy it is.


Booticus(Posted 2006) [#9]
*looks warily at SQLite mod*

OOOKKKKKKKK, I'll see what I can come up with.....

;)


René(Posted 2006) [#10]
Hey Booticus,

sorry, I was out of office for some days.
If you still want to try with SQLiter this would be very easy.

Use TSQLiter.query_col_list.
This list holds the name of every column involved in the last query. So to get all column names you should query something like "SELECT * FROM test_table". The asterisk ensures that all columns are involved.

The following example works with the test table that comes with the SQLiter package.

SuperStrict

Import pyropixel.sqliter


'Create new SQLite Object
	Global db:TSQLiter = New TSQLiter

'Open Database File
	db.Open("test.db")


'A query
	db.Query("SELECT * FROM test_table")

'Print out all column name
	For Local c:String = EachIn TSQLiter.query_col_list
		DebugLog "Column:"+ c
	Next


'Close database
	db.Close()

End



René(Posted 2006) [#11]
Hi there,

use version 1.02 of SQLiter. The new version offers some new methods to explore and read database schemes. Now it should be easy to read all infos from a database to copy it for example.


Booticus(Posted 2006) [#12]
EXCELLENT!! thank you!!


siread(Posted 2006) [#13]
I've extracted the rar in C:\Program Files\BlitzMax\mod but i'm getting error:

Can't find interface for module 'pyropixel.sqliter'

What have i done wrong?


René(Posted 2006) [#14]
Sorry, on the website I did not mention,that you have to compile the module with BlitzMax' bmk tool.
Do you now how to compile a module? Otherwise I could send you a compiled module. Which OS do you use?


siread(Posted 2006) [#15]
Ahhhh, ok. I'm sorted now. Thanks. :D


AD(Posted 2006) [#16]
My question is;
Doesn't the end-user have to have MySQL installed for this to work? Does this framework automatically package mysql?


René(Posted 2006) [#17]
No, SQLite does not need a server system. Everything is file based. SQLite does not use MySQL in any way. MySQL and SQLite are both database systems that use SQL as their query language. MySQL needs a server, SQLite does not. Therefore the SQL command set of SQLite does not support as many SQL commands as MySQL does. But that should be only a problem for very complicated database operations.


Booticus(Posted 2006) [#18]
"....SQLite does not need a server system. Everything is file based. SQLite does not use MySQL in any way."

THATS why I was so pleased with SQLite as an option. The power and flexibility of SQL without the hassle of installing a "server" app on the local machine. René has been very helpful to me and my questions too. Anyone who hasn't tried SQLiter out yet is definitely missing out on a fun experience!


Rook Zimbabwe(Posted 2006) [#19]
Rene this looks fantastic... I just wish I could use it in B3D or B+!!! oh well anothe reason to upgrade.


xlsior(Posted 2006) [#20]
I missed this thread the first time around -- certainly looks like a very interesting module, especially since it seems to allow you to create a DB on the fly in RAM as well, and use it to organize data for your application.