SQLite update new record, save old.

vdudukov

Member
Licensed User
Longtime User
Hello

I dont know how to solve this problem. I have some records in db, and now i want to add few new records into db, but I dont want to lose old records. I searched for answer, but i did not find anything.
 
Do tuo want to have a new record every time you do an update?:)

Yes,. My application has SQLite database, and when i update a new version of application with new records, i just want to add new one, old data must stay in database. Simple, if in old version i have in database "horse", and in new version i have "cow", when i update new version of app, i want in database "horse" and "cow":-)
 
Last edited:
Upvote 0
If this is not happening, it sounds like you may be overwriting the database. Can you post your code (file menu Export as Zip).
 
Upvote 0
You can create a second table to store the history using a trigger on the first table
:)


Here is my SQL initialize code. Maybe somethingis wrong.

If File.Exists(File.DirInternal,"database.sql") = False Then File.Copy(File.DirAssets,"database.sql",File.DirInternal,"database.sql")
End If
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirInternal, "database.sql", False)
End If

I am thinking about somekind of import from txt or csv to sql.
 
Upvote 0
Here is my SQL initialize code. Maybe somethingis wrong.

If File.Exists(File.DirInternal,"database.sql") = False Then File.Copy(File.DirAssets,"database.sql",File.DirInternal,"database.sql")
End If
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirInternal, "database.sql", False)
End If

I am thinking about somekind of import from txt or csv to sql.

This is the code I use for importing from csv in my app.

Code:
Dim su As StringUtils
   Dim Table As List
   Table = su.LoadCSV(File.DirAssets, "matrix.csv", ";")
   Dim Table2 As List
   Dim Items() As String
   Table2.Initialize
      For i = 0 To Table.Size - 1
          Items = Table.get(i)
             Dim m As Map
             m.Initialize
             m.Put("panel", Items(0))
              m.Put("cat", Items(1))
               m.Put("size", Items(2))
                m.Put("price", Items(3))
             m.Put("alum", Items(4))
             m.Put("access", Items(5))
               m.Put("largepanel", Items(6))
                m.Put("oversized", Items(7))
             m.Put("oversizednum", Items(8))
              m.Put("extra1", Items(9))
               m.Put("extra2", Items(10))
                m.Put("extra3", Items(11))
          Table2.Add(m)
      Next

      DBUtils.InsertMaps(Main.SQL1, "matrix", Table2)
 
Upvote 0
This is the code I use for importing from csv in my app.

Code:
Dim su As StringUtils
   Dim Table As List
   Table = su.LoadCSV(File.DirAssets, "matrix.csv", ";")
   Dim Table2 As List
   Dim Items() As String
   Table2.Initialize
      For i = 0 To Table.Size - 1
          Items = Table.get(i)
             Dim m As Map
             m.Initialize
             m.Put("panel", Items(0))
              m.Put("cat", Items(1))
               m.Put("size", Items(2))
                m.Put("price", Items(3))
             m.Put("alum", Items(4))
             m.Put("access", Items(5))
               m.Put("largepanel", Items(6))
                m.Put("oversized", Items(7))
             m.Put("oversizednum", Items(8))
              m.Put("extra1", Items(9))
               m.Put("extra2", Items(10))
                m.Put("extra3", Items(11))
          Table2.Add(m)
      Next

      DBUtils.InsertMaps(Main.SQL1, "matrix", Table2)

Great. Thank You, i wiil try :-)
 
Upvote 0
Is there possibility to use Second Sqlite database, only for reading records?
Can I read records from two databases at the same time?
 
Upvote 0
Back
Top