B4J Question How to execute SQLite dump list ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

Never tried, but if to update the db remotely, i think it's easy to prepare the DB dump text file, and execute after downloading.


But how to execute it in B4J and B4A ?
 
Last edited:

aeric

Expert
Licensed User
Longtime User
I only can think to use the query batch run the commands one by one
B4X:
SQL.AddNonQueryToBatch(Query1, Null)
SQL.AddNonQueryToBatch(Query2, Null)
SQL.AddNonQueryToBatch(Query3, Null)
Dim sf As Object = SQL.ExecNonQueryBatch("SQL")
Wait For (sf) SQL_NonQueryComplete (Success As Boolean)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Maybe this help.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Used some workaround:
B4X:
Sub Execute_DBDump(path As String, sql_object As SQL)
    If File.Exists("", path) = False Then Return
    Dim s() As String = Regex.Split(CRLF, File.ReadString("", path))
    For i = 0 To s.Length - 1
        sql_object.ExecNonQuery(s(i))
    Next   
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I think it is less prone to errors to use a list:
B4X:
Sub Execute_DBDump(path As String, sql_object As SQL)
    If File.Exists("", path) = False Then Return
    Dim MyList As List= File.ReadList("", path)
    For Each s As String In MyList
        sql_object.ExecNonQuery(s)
    Next
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…