B4i Library [module] DBUtils

Latest version available here: https://www.b4x.com/android/forum/threads/b4x-dbutils-2.81280/

B4i implementation of DBUtils: http://www.b4x.com/android/forum/threads/8475/#content

SS-2014-11-06_16.31.38.png


DBUtils v1.10 - CreateTable now accepts two lists instead of a map for the columns and their types. The reason for this is that maps in B4i do not preserve the order and the order of columns can be important. Note that the updated CreateTable sub can be copied as is to B4A.
 

Attachments

  • DBUtils.zip
    8.3 KB · Views: 230
Last edited:

ivan.tellez

Active Member
Licensed User
Longtime User
Hi @Erel , I want to notify a probably "Bug" in the Module.

As you stated in the files and folders, thenon-user generated persistent files should be stored in the DirLibrary, not in the DirDocuments as in the current implementation of DBUtils.

The problem is when you implement some functionality that require user generated files, for example, if you use UIFileSharingEnabled, then, the databases will be accesible to the user.

Is this correct or maybe I misundertood the DirLibrary function?

Thanks
 

RVP

Active Member
Licensed User
Longtime User
Missing ExecuteMapList ?

There is a ExecuteMemoryMap, but it doesn't return maps

Sorry , ExecuteMapList was something I added in B4A.
 
Last edited:

RVP

Active Member
Licensed User
Longtime User
Here is the B4I code for ExecuteMapList

B4X:
'Executes the query and returns a List of Maps with the column names as the keys 
'The keys are lower cased.
'Returns an uninitialized list if no results found.
Sub ExecuteMapList(SQL As SQL, Query As String, StringArgs() As String, Limit As Int) As List ' ******* RVP Added
    Dim rs As ResultSet = SQL.ExecQuery2(Query, StringArgs)
    Log("ExecuteMapList: " & Query)
    Dim TableList As List
    Dim count As Int = 0
   
    Do While rs.NextRow
        If     TableList.IsInitialized = False Then TableList.Initialize
        count = count+1
        If count <= Limit Or Limit = 0 Then
           
            Dim res As Map
            res.Initialize
            Dim values(rs.ColumnCount) As String
            For col = 0 To rs.ColumnCount - 1
                Try
                    res.Put(rs.GetColumnName(col).ToLowerCase, rs.GetString2(col))
                Catch
                    Dim  byt() As Byte: byt  = rs.GetBlob2(col)
                    res.Put(rs.GetColumnName(col).ToLowerCase, BytesToString(byt,0,byt.Length,"UTF8"))
                End Try
            Next
            TableList.Add(res)
        End If
    Loop
    rs.Close
    Return TableList
End Sub
 
Last edited:

Myr0n

Active Member
Licensed User
Longtime User
Top