3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: 1 2 3 [4] 5

Author Topic: RadSqLite Released.  (Read 9506 times)

jestermon

« Reply #45 on: July 15, 2010, 05:48:59 PM »
Foreign key constraints were implemented since SQLite version 3.6.19, and I currently use SQLite version 3.5.6 for DevCpp. Alhough there is a SQLite version 3.6.22 for DevCpp available, it is not stable enough for my requirements. So I cannot provide you with this feature at this time, as much as I would love to help.
... however
Prior versions of SQLite parsed foreign key constraints, but did not enforce them. The equivalent functionality could be implemented using SQL triggers http://www.sqlite.org/lang_createtrigger.phpl

I would suggest that when applying triggers to your database, that they be entered with some 3rd party tool, since the RadSqLite interface was written primarily as a client interface, and I have not yet tested loading triggers through it.

Hope this helps


« Last Edit: July 15, 2010, 06:34:05 PM by jestermon »

psikotropico

« Reply #46 on: July 25, 2010, 04:48:35 AM »
hi jestermon... still fighting with SQLite... ;D

one question: is there any characters limit in the query string? Now I have a big database with about 80 fields (and more to come) but in the debug txt file only appears the first 60-65 fields in the query... (attached debug file)

thanks!

jestermon

« Reply #47 on: July 25, 2010, 06:46:30 AM »
hi jestermon... still fighting with SQLite... ;D

one question: is there any characters limit in the query string? Now I have a big database with about 80 fields (and more to come) but in the debug txt file only appears the first 60-65 fields in the query... (attached debug file)

thanks!
The query response line length is set to 1024 characters, but I will up this for you to 4K as soon as I get the chance. Thanks for pointing this out.

jestermon

« Reply #48 on: July 25, 2010, 07:07:02 AM »
The query response string length, as well as the debug display string length have been increased to 4096. This should be ample for game purposes.
« Last Edit: July 25, 2010, 07:23:36 AM by jestermon »

psikotropico

« Reply #49 on: July 25, 2010, 08:56:26 AM »
 :-*

psikotropico

« Reply #50 on: July 25, 2010, 10:50:15 AM »
oops!... still having problems... sorry if I'm loud but there's the same syntax error in the debug file (attached)... I think there are no errors in the script, anyway, here is the code I'm using to make the query:

Code: [Select]
void CreateProfile() {
   string table = "PlayerProfile";        //the name of the table
   sql = "select * from " + table + ";";
   doSql();
   extractDB();

   int count    = getRecordcount();
   PlayerID     = (count+1);
   PlayerMoney  = 50000;

   //set current player
   CurrPlayer = PlayerID;
   //make this player active
   PlayerActive = 1;
   //disable all other players
   SetInactivePlayers();

   sql =  "insert into " + table + " (";
   //fields
   sql += "Player_id,";
   sql += "Player_active,";
   sql += "Player_name,";
   sql += "Player_money,";
   sql += "Player_gamemode,";
   sql += "Settings_sound_sfxvolume,";
   sql += "Settings_sound_gamevolume,";
   sql += "Settings_sound_menuvolume,";
   sql += "Settings_sound_track,";
   sql += "Settings_display_arrows,";
   sql += "Settings_display_map,";
   sql += "Settings_display_speed,";
   sql += "Settings_display_hud,";
   sql += "Settings_controls_slide,";
   sql += "Settings_controls_device,";
   sql += "Car_CurrentCar,";
   sql += "Car_SetupBrake,";
   sql += "Car_SetupSpeed,";
   sql += "Car_SetupAcc,";
   sql += "Car_SetupReverse,";
   sql += "Car_SetupBrakePower,";
   sql += "Car_SetupFGrip,";
   sql += "Car_SetupFGripLat,";
   sql += "Car_SetupRGrip,";
   sql += "Car_SetupRGripLat,";
   sql += "Car_Owner1,";
   sql += "Car_Owner2,";
   sql += "Car_Owner3,";
   sql += "Car_Owner4,";
   sql += "Car_Owner5,";
   sql += "Car_Owner6,";
   sql += "Car_Owner7,";
   sql += "Car_Active1,";
   sql += "Car_Active2,";
   sql += "Car_Active3,";
   sql += "Car_Active4,";
   sql += "Car_Active5,";
   sql += "Car_Active6,";
   sql += "Car_Active7,";
   sql += "ArcadeCurrMoon,";
   sql += "ArcadeCurrTrack,";
   sql += "ArcadeCurrTrackMode,";
   sql += "ArcadeCurrDifficulty,";
   sql += "ArcadeMoonActive1,";
   sql += "ArcadeMoonActive2,";
   sql += "ArcadeMoonActive3,";
   sql += "ArcadeMoonActive4,";
   sql += "ArcadeMoonActive5,";
   sql += "ArcadePosA01,";
   sql += "ArcadePosA02,";
   sql += "ArcadePosA03,";
   sql += "ArcadePosA04,";
   sql += "ArcadePosA05,";
   sql += "ArcadePosA06,";
   sql += "ArcadePosA07,";
   sql += "ArcadePosA08,";
   sql += "ArcadePosA09,";
   sql += "ArcadePosA10,";
   sql += "ArcadePosA11,";
   sql += "ArcadePosA12,";
   sql += "ArcadePosA13,";
   sql += "ArcadePosA14,";
   sql += "ArcadePosA15,";
   sql += "ArcadePosB01,";
   sql += "ArcadePosB02,";
   sql += "ArcadePosB03,";
   sql += "ArcadePosB04,";
   sql += "ArcadePosB05,";
   sql += "ArcadePosB06,";
   sql += "ArcadePosB07,";
   sql += "ArcadePosB08,";
   sql += "ArcadePosB09,";
   sql += "ArcadePosB10,";
   sql += "ArcadePosB11,";
   sql += "ArcadePosB12,";
   sql += "ArcadePosB13,";
   sql += "ArcadePosB14,";
   sql += "ArcadePosB15";//<-- last field!!

   sql += ") values (";
   //values
   sql += PlayerID + ",";
   sql += "1,";
   sql += "'" + PlayerName + "'" + ","; //strings fields must have "'"
   sql += PlayerMoney + ",";
   sql += PlayerGameMode + ",";
   sql += settings_sound_sfx_volume + ",";
   sql += settings_sound_game_volume + ",";
   sql += settings_sound_menu_volume + ",";
   sql += settings_sound_soundtrack + ",";
   sql += settings_display_arrows + ",";
   sql += settings_display_map + ",";
   sql += settings_display_speed + ",";
   sql += settings_display_hudop + ",";
   sql += settings_controls_slide + ",";
   sql += settings_controls_device + ",";
   sql += car_current_car + ",";
   sql += car_setup_brake + ",";
   sql += car_setup_speed + ",";
   sql += car_setup_acc + ",";
   sql += car_setup_reverse + ",";
   sql += car_setup_brakepower + ",";
   sql += car_setup_fgrip + ",";
   sql += car_setup_fgriplat + ",";
   sql += car_setup_rgrip + ",";
   sql += car_setup_rgriplat + ",";
   sql += car_owner1 + ",";
   sql += car_owner2 + ",";
   sql += car_owner3 + ",";
   sql += car_owner4 + ",";
   sql += car_owner5 + ",";
   sql += car_owner6 + ",";
   sql += car_owner7 + ",";
   sql += car_active1 + ",";
   sql += car_active2 + ",";
   sql += car_active3 + ",";
   sql += car_active4 + ",";
   sql += car_active5 + ",";
   sql += car_active6 + ",";
   sql += car_active7 + ",";
   sql += ArcadeCurrMoon + ",";
   sql += ArcadeCurrTrack + ",";
   sql += ArcadeCurrTrackMode + ",";
   sql += ArcadeCurrDifficulty + ",";
   sql += ArcadeMoonActive1 + ",";
   sql += ArcadeMoonActive2 + ",";
   sql += ArcadeMoonActive3 + ",";
   sql += ArcadeMoonActive4 + ",";
   sql += ArcadeMoonActive5 + ",";
   sql += ArcadePosA01 + ",";
   sql += ArcadePosA02 + ",";
   sql += ArcadePosA03 + ",";
   sql += ArcadePosA04 + ",";
   sql += ArcadePosA05 + ",";
   sql += ArcadePosA06 + ",";
   sql += ArcadePosA07 + ",";
   sql += ArcadePosA08 + ",";
   sql += ArcadePosA09 + ",";
   sql += ArcadePosA10 + ",";
   sql += ArcadePosA11 + ",";
   sql += ArcadePosA12 + ",";
   sql += ArcadePosA13 + ",";
   sql += ArcadePosA14 + ",";
   sql += ArcadePosA15 + ",";
   sql += ArcadePosB01 + ",";
   sql += ArcadePosB02 + ",";
   sql += ArcadePosB03 + ",";
   sql += ArcadePosB04 + ",";
   sql += ArcadePosB05 + ",";
   sql += ArcadePosB06 + ",";
   sql += ArcadePosB07 + ",";
   sql += ArcadePosB08 + ",";
   sql += ArcadePosB09 + ",";
   sql += ArcadePosB10 + ",";
   sql += ArcadePosB11 + ",";
   sql += ArcadePosB12 + ",";
   sql += ArcadePosB13 + ",";
   sql += ArcadePosB14 + ",";
   sql += ArcadePosB15 + ");";//<-- last field!!
   doSql();
}

also, I have the debugOn() function inactive (it's commented at iInitializing) but the debug file still appears in the 3dRad folder... is this usual?

thanks in advance!

jestermon

« Reply #51 on: July 25, 2010, 11:05:58 AM »
Ok, this time it is your sql statement that is longer than catered for. I've set the sql query buffer to 4k as well, so that should clear up your problem. :)

psikotropico

« Reply #52 on: July 25, 2010, 11:26:31 AM »
thanks again... not sure if this is the correct way to do this... maybe I'm using too many fields?... I'm thinking on create another table to store race results and so on but not sure if I will have problems linking tables between them...

jestermon

« Reply #53 on: July 25, 2010, 11:35:23 AM »
thanks again... not sure if this is the correct way to do this... maybe I'm using too many fields?... I'm thinking on create another table to store race results and so on but not sure if I will have problems linking tables between them...
You can do a query from multiple tables at a time with the "as" keyword.. for example (just a sample - not tester)
select nm.name, nm.surname, jb.description, jb.salary from nametable as nm, jobtable as jb where jb.salary > 30000;
Here you use "nametable as nm"  so you use the "nm." as part for the column name.
Also you can use shorter meaningful names for the columns, which can save some bytes.. but 4k is a lot to play around with... :)

Regarding the debug... If SqLite (not RadSqLite) picks up a syntax or other serious errors, I automatically turn the logging on, so that the problem is reported somewhere.. Just a nice way to tell you you made a booboo, or in this case, the sql was not completed because of the short buffer, so it came through as an error.


« Last Edit: July 25, 2010, 11:36:55 AM by jestermon »

jestermon

« Reply #54 on: July 25, 2010, 01:02:35 PM »
A hint on doing a SQL query on multiple tables by using the �as� keyword

Let us assume you are using three tables. CarData, RaceData and UserData
The CarData table has fields: CarID, Color, Model, Year, Class
The RaceData table has fields: RaceID, CarID(used to link to Car), RaceClass, TimeStart.
The UserData table has fields: UserID, UserName, CarID(link user's car), Country

In design, the CarID in all three tables can be used to link them together for example.
UserID=10 has a car with CarID=102. CarID has been entered into a raced with RaceID=6, and RaceID=9.

Let us use the �as� keywords, and make short names for the tables. UserData as US, CarData as CR and RaceData as RC. (These are imaginary). So we can now link everything together with a Sql query that looks something like this.

SELECT US.UserID. US.UserName, US.CarID, RC.RaceID, RC.RaceClass from
UserData as US, RaceData as RC, CarData as CR
WHERE US.UserID=10 and US.CarID=102 and RC.RaceID=6 and RC.RaceID=9
and CR.CarID=US.CarID and RC.CarID=US.CarID

The 4 lines must be sent as a single line of sql.. but is broken up to explain........
The first line selects all the fields (with table short names) from the different tables that you want to retrieve.
The second line uses the �as� keyword to give short names for the tables.
The third line specifies all the key data to search for.
The fourth line specifies the links, in other words, where the CarID matches in all the tables.

It may look confusing at first, but SQL is a very powerful language that can do very complex searches from multiple tables, provided that they all share something in common. In this case the CarID field.

What's interesting about this example, is that US.UserID can have many cars (CarID's), and each car can be entered into many races (RaceID's). Notice that there is no RaceID in the UserData table, since a car can be entered into a race, not a user.. (in this example).. But the CarID link gets all the required race information


jestermon

« Reply #55 on: July 25, 2010, 02:48:59 PM »
An interesting snipt of information about SqLite

SQLite will easily do 50,000 or more INSERT statements per second on an average desktop computer. But it will only do a few dozen transactions per second. Transaction speed is limited by the rotational speed of your disk drive. A transaction normally requires two complete rotations of the disk platter, which on a 7200RPM disk drive limits you to about 60 transactions per second.

Transaction speed is limited by disk drive speed because (by default) SQLite actually waits until the data really is safely stored on the disk surface before the transaction is complete. That way, if you suddenly lose power or if your OS crashes, your data is still safe

So if you are planning a huge chunk of insert, using frame counted inserts.. ie. a few inserts per frame, you can ensure that you don't effect the frame rate of your game.

psikotropico

« Reply #56 on: July 26, 2010, 12:02:02 AM »
brilliant...

jestermon

« Reply #57 on: July 26, 2010, 05:32:03 AM »
« Reply #58 on: December 17, 2011, 08:59:39 PM »
I love what I have read. Can you post a new download link. I get a php file when I click on the links in this thread.

jestermon

« Reply #59 on: December 18, 2011, 02:31:57 AM »
I love what I have read. Can you post a new download link. I get a php file when I click on the links in this thread.

The links do actually still exist. . .

You are probably using Firefox. It has a problem with the latest releases, in that it messes up links. The way around this, is to right click on the link, and open the page or link in a new tab. If it's a download, the download will start soon, and leave you with a blank page on the new tab. Just close the empty tab.
Hope this helps.
« Last Edit: December 18, 2011, 02:33:50 AM by jestermon »
Pages: 1 2 3 [4] 5