开发者

SQLite database to MySQL database daily migration / updating new fields

I have a SQLite database that 开发者_JS百科is created by reading some data in PDF files using Java. Every day (or almost) I have new PDF files to read that create new rows in some tables in my SQLite database.

Eventually, what I'd like to do is make the data in that database available on the internet using a MySQL database accessed by my website. The thing is, I have searched on Google, to no avail, how to migrate my database to MySQL. Of course I have found some programs to do so, but they don't let me do it in an automated manner every day at midnight.

Also, if it's possible, I'd rather do it another way: only updating the new rows that were added and migrate only those instead of recreating the whole database daily.

I don't know what the best way to do something like this is, so if the tags are wrong, I'm sorry about it.

The computer that runs the java program to create / update the SQLite database is running Windows Vista, if it matters.


You could include a timestamp in your SQLite table and set the default value to the time when the record was inserted (default now should do the trick). Then, you'd need a table in your MySQL database (or your SQLite database, whichever works better for you) that contains a single timestamp, this will be your "last imported time".

When it is time to do your data transfer:

  • Grab the last-imported-time.
  • Store the current timestamp in t.
  • Grab everything from your SQLite database that is newer than t and copy it to your MySQL database.
  • Update the last-imported-time in your database to t from above.

Storing the timestamp that you're using in t helps you avoid missing anything.

If you're also updating things in your SQLite database rather than just inserting things, then you could add another timestamp for the "last modified time". Then apply the same logic as above with "copy" replaced with "update" or "delete and re-insert".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜