B4J Code Snippet [SQL] DButils v.2.5 for SQLite and MySQL

One my project has to be using not only SQLite database (actually, two different ones, as separate classes), but MySQL also, due to big size that now is more convenient to see via web-browser remotely (without downloading big SQLite db file).

So, i have combined 2 DBUtils modules:

It's not so good to switch the db type (SQLite or MySQL) during usage:
B4X:
'MySQL additions:
'Added to give EscapeField more flexibility
Public Sub SetEscapeChars(MySQL As Boolean)
    If MySQL Then
        escapeCharStart = "`"
        escapeCharEnd = "`"
        isMySQL = True
    Else
        escapeCharStart = "["
        escapeCharEnd = "]"
        isMySQL = False
    End If
End Sub

'usage:

DBUtils2.SetEscapeChars(True)
DBUtils2.InsertMaps(db.SQL, "sorting", L)

, but it works in such complex project OK, tested.

Please, post your suggestions how to modify for more easy and correct usage with both db kinds.
 

Attachments

  • DBUtils2.bas
    22.1 KB · Views: 87
Last edited:
Top