Data Base

Connection DB

Connect to register DB in Base.

Sub ConnectDB()
    db_name = "test"
    user = ""
    pass = ""
    con = util.conDB(db_name, user, pass)

    util.msgbox(con.isClosed())
End Sub

Verify if exists.

db_name = "test"
MsgBox util.existsDB(db_name)

If exists, get path location.

db_name = "test"
If util.existsDB(db_name) Then
    MsgBox util.getPathDB(db_name)
End If

Create DB and register in Base.

path_db = "/home/USER/dbtest.odb"
db_name = "TestOne"
util.newDB(path_db)
util.registerDB(db_name, path_db)

Revoke register DB.

db_name = "test"
util.revokeDB(db_name)

ODBC

I test connection with: MySQL, PostgreSQL, SQLite and MSSQL.

Sub ConexionODBC()

    util = createUnoService("org.universolibre.EasyDev")

    odbc = "ConSQL"
    user = "sa"
    passw = "letmein"

    con = util.conODBC(odbc, user, passw)

    util.msgbox(con)

End Sub

Query

Make query, get data like array

odbc = "ODBCSQLITE"
user = ""
passw = ""
con = util.conODBC(odbc, user, passw)

sql = "SELECT * FROM contactos"
data = util.query(con, sql, True)
util.msgbox(data)

Make query, get data like resulset

sql = "SELECT * FROM contactos"
data = util.query(con, sql, False)
util.msgbox(data)

You can set resulset to grid, see Grid.

Update

Insert data.

sql = "INSERT INTO ""directory"" VALUES (6, 'Nikole Kidman', '1970-01-15', 'nikole@correo.com')"
row = util.update(con, sql)
util.msgbox(row)

Update data.

sql = "UPDATE ""directory"" SET ""email""='nk@coreo.com' WHERE ""id""=6"
row = util.update(con, sql)
util.msgbox(row)

Delete data.

sql = "DELETE FROM ""directory"" WHERE ""id""=5"
row = util.update(con, sql)
util.msgbox(row)