The online racing simulator
SQL Database Guru Wanted
Hi

I use LFSLapper, which since a number of releases ago, now saves driver lap times, etc., in SQLite databases, rather than in a txt file.

With some of these newer releases, I've usually copied the SQLite database data from one release over to another.

Only thing is, I use 2 different host operators to run a server each, and although they both support LFSLapper, they haven't always kept up with the releases (not their fault, as some of the releases have been minor, but frequent).

Problem I have, is that I now have a number of different SQLite databases, including copies from old releases, that I would like to merge together to give me a definative master database that I can use.

I would also like every so often to merge the databases from both servers, and use that as the new master.

i.e..
Then put SQL_Master on both servers, overwriting both originals.
Later, take databases from both servers and merge to make newer master () which, again, would be loaded onto both servers. SQL_Mas1_Serv1+SQL_Mas1_S2=SQL_M2. And continue the process.

Process-
Quote :
Upload files from both servers, and merge: SQL_Serv_1+SQL_Serv_2=SQL_Master1
Put merged file on both servers: SQL_Master1 put on Serv_1 and Serv_2
Upload files from both servers, and merge: SQL_Master1_Serv1+SQL_Master1_Serv2=SQL_M2
Put merged file on both servers: SQL_M2 put on Serv_1 and Serv_2
Upload files from both servers, and merge: SQL_M2_Serv1+SQL_M2_Serv2=SQL_M3

Unfortunately, I don't know how to use SQLite, and though I've been reading up on it, I'm finding I'm not understanding it at all.

I can't seem to make the jump from MS Access, which I've been using for over 10 years (as well as Paradox [DOS and Windows versions] before that) to SQLite.

So.

Is there a free gui type SQL program that will take my 2 SQL databases, merge them, remove all the duplicates (likely to be many), then (the hardest part), where someone has done the same car/track combo again and if new lap time is faster (one or more of the individual time sectors may actually be slower), remove slower lap time entry. Don't want a !top table that shows multiple entries for same driver in same car on same track.

Or if no SQL program that will do that automatically (highly unlikely), a free SQL program with additional query, specially written by yourself(!), that will do same thing? Then output data into new database using same database files formats (.dbs + .elp) that LFSLapper will understand and add to.

Copy of some old database files attached, along with output table (!top).
Attached images
LFSLapper !top table.PNG
Attached files
Sinanju_SQL.rar - 1004 KB - 169 views
It sounds like what you really want is a multi-master/bi-directional replication.

SQLite isn't a fully featured SQL database so it doesn't have this built in by default. Other SQL engines, such as MySQL, SQL Server, PostgreSQL, etc. all have this feature. There are SQLite servers that will make SQLite addressable from multiple machines at the same time, over their own network protocol, but thats just a poormans version of a proper SQL server and you'd need to modify lapper to support it anyway.

If you wanted to do it automatically every X hours you'd have to roll your own script to merge multiple SQLite databases - it wouldn't be too hard - you just need to give each entry its own unique id and the last change time of each row, and then check each row that doesn't match in each database and update where necessary (most recent update wins - but you'd need to always favour one in the event that both get updated at the exact same time).

I've not looked at the databases you've provided, but in theory it's possible. You'd most likely need to make some alterations to your SQLite database - either LFSLapper would need to update a column recording the datetime of the row change, or you'd need to add a trigger to each table that does this instead.

I don't have time to produce something that would do this, although once you've got the datetime and primary keys in the database it's actually fairly trivial as you can make the script or program intelligently able to cope with any table by utilising the describe statement, but hopefully this will help you/someone along with the process.

Edit: I've just realised I might've gone off on a tangent and not actually answered your question - if thats the case then I apologise.
#3 - herki
I don't know if it helps you, but SQLite Browser allows you to browse SQLite DBs and run queries on them.

FGED GREDG RDFGDR GSFDG