Game Development Community

Another Sqlite Blog

by Frank Carney · 12/24/2007 (7:07 am) · 1 comments

I finally picked up where I left off last September and messed with writing sqlite functions. I made some great strides in figuring out how to copy a table and changing a field name in the process. It is a pain to do, but it was not too bad. Basically I had to use a combination of "pragma" statements to get column information and copy the data except for the rows that do not match. I cannot understand why sqlite would care if I copied data from one row to another of a different name. Either that or it does not understand my intentions. If anyone understands how to copy something like this:
INSERT INTO table2(p,a,b) SELECT c,a,b FROM table1
This code failed with type miss match messages.

How do I get sqlite to copy the data from c to p? I ended up ignoring that field as it is an PRIMARY KEY field. I ended up doing this:
INSERT INTO table2(a,b) SELECT a,b FROM table1
I figured it would generate the necessary values on its own.

I have developed a number of helper functions for creating databases, creating game specific tables, etc. My next step is to actually produce a dynamic mission from this information. Hopefully I can get something working in the next few days. Alas the holidays are upon me and that time may be spoken for.

Also, I uncovered a couple of bugs in the sqliteobject code. I put those changes in the following resource page:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7281

Merry Christmas everyone!!!
May God bless you.

#1
12/24/2007 (8:48 pm)
Maybe I am an idiot, but transactions are really cool! It is fault tolerance! I just changed one of my routines to bound the changes to the database in a transaction. I also introduced an error on purpose in one of the queries. It detected the error and rolled back the transactions. This is very cool. Definitely can improve data integrity and prevent the database from getting all hosed up. To think I was manually going back and changing the name of a table every time a query failed during the copy process! I could have bounded it all in a transaction and saved me time during development.

Messing with sqlite definitely is fun. I used to think database stuff was really boring. It is actually very interesting.