MiniORMUtils
Version: 4.30
This library can be use for creating database tables and performing CRUD operations.
It is suitable for B4X apps, non-UI web app or REST API servers.
It is useful to return the query results as JSON since the rows are list of maps.
Currently it supports SQLite (for B4A, B4i, B4J), MariaDB and MySQL (for B4J only).
Project Template:
[B4X] [Project Template] MiniORM
Examples:
Initialize MiniORM
Check if database exist
Create Database
Connect to Database
Create Table
Insert Rows
Execute NonQuery Batch
Select All Rows
Update Row
GitHub: https://github.com/pyhoon/MiniORMUtils-B4X
www.b4x.com
Version: 4.30
This library can be use for creating database tables and performing CRUD operations.
It is suitable for B4X apps, non-UI web app or REST API servers.
It is useful to return the query results as JSON since the rows are list of maps.
Currently it supports SQLite (for B4A, B4i, B4J), MariaDB and MySQL (for B4J only).
Project Template:
[B4X] [Project Template] MiniORM
Examples:
Initialize MiniORM
B4X:
Private DB As MiniORM
Private MS As ORMSettings
MS.Initialize
MS.DBType = "SQLite"
MS.DBFile = "data.db"
MS.DBDir = File.DirApp
DB.Initialize
DB.Settings = MS
Check if database exist
B4X:
If Not(DB.Exist) Then
LogColor($"${MS.DBType} database not found!"$, COLOR_RED)
CreateDatabase
End If
Create Database
B4X:
Dim Success As Boolean = DB.InitializeSQLite
Connect to Database
B4X:
DB.SQL = DB.Open
Create Table
B4X:
DB.Table = "tbl_category"
DB.Columns.Add(DB.CreateColumn2(CreateMap("Name": "category_name")))
DB.Create
Insert Rows
B4X:
DB.Columns = Array("category_name")
DB.Insert2(Array("Hardwares"))
DB.Insert2(Array("Toys"))
Execute NonQuery Batch
B4X:
Wait For (DB.ExecuteBatchAsync) Complete (Success As Boolean)
If Success Then
Log("Database is created successfully!")
Else
Log("Database creation failed!")
End If
DB.Close
Select All Rows
B4X:
DB.Table = "tbl_category"
DB.Query
If DB.Error.IsInitialized Then
Log(DB.Error.Message)
Else
Dim Items As List = DB.Results
End If
Update Row
B4X:
DB.Table = "tbl_products"
DB.Columns = Array("category_id", "product_code", "product_name", "product_price")
DB.Id = 2
DB.Save2(Array(Category_Id, Product_Code, Product_Name, Product_Price))
GitHub: https://github.com/pyhoon/MiniORMUtils-B4X
[B4X] MiniORMUtils - SQL Query Builder
Updates Version 2.00 is available https://www.b4x.com/android/forum/threads/b4x-miniormutils.166030/ MiniORMUtils Version: 1.17 This library can be use for creating db schema and performing CRUD operations. It is suitable for Web API Template or any database system. Currently it supports...
Attachments
Last edited: