DIAdem Help

Content Type
Programming Language
Current manual
Table of Contents

Command: SQLiteOpen

Display all  Hide all

Command: SQLiteOpen

Opens an SQLite database file in read and write mode. If the database does not exist, DIAdem creates a new database property. Since only one database can be open at a time, DIAdem first closes an already open database before opening the new database.

Call SQLiteOpen(SQLiteDatabase)

Input Parameters

SQLiteDatabase Specifies the name of the SQLite database.

Example

The following example opens the SQLite database "Cities_1000_V4.4.sqlite" and loads the database extension "mod_spatialite4.dll" with the entry point  "sqlite3_modspatialite_init". The example then performs various searches in the database and displays the results in the logfile.

VBScriptPython

 

Call SQLiteOpen(DataReadPath & "Cities_1000_V4.4.sqlite")
Call SQLiteAddExtension("mod_spatialite4.dll", "sqlite3_modspatialite_init")
Call SQLQuery("SELECT Name FROM cities1000 LIMIT 10;", True)
Call SQLQuery("SELECT Name FROM cities1000 ORDER BY Distance(geom_wsg84, MakePoint(cast(12.4876180 AS DOUBLE), cast(41.9029000 AS DOUBLE), 4326)) LIMIT 5;", True)
Call SQLQuery("SELECT * FROM knn WHERE f_table_name = 'cities1000' AND ref_geometry = MakePoint(cast(12.4876180 AS DOUBLE), cast(41.9029000 AS DOUBLE)) LIMIT 5;", True)
Call SQLQuery("SELECT Name FROM cities1000 LIMIT 10;", False)
Call SQLQuery("SELECT Name FROM cities1000 ORDER BY Distance(geom_wsg84, MakePoint(cast(12.4876180 AS DOUBLE), cast(41.9029000 AS DOUBLE), 4326)) LIMIT 5;", False)
Call SQLQuery("SELECT * FROM knn WHERE f_table_name = 'cities1000' AND ref_geometry = MakePoint(cast(12.4876180 AS DOUBLE), cast(41.9029000 AS DOUBLE)) LIMIT 5;", False)
Call SQLiteClose()

Sub SQLQuery(sQuery, bOutputHeader)
  Dim aResult, sText, iRow, iColumn
  Call LogFileWrite("sQuery: " & sQuery)
  Call LogFileWrite("-----------------------------")
  Result = SQLiteQuery(sQuery, bOutputHeader)
  If IsArray(aResult) Then
    For iRow = lBound(aResult,1) To uBound(aResult,1)
      sText = ""
      For iColumn = lBound(aResult, 2) To uBound(aResult,2)
        sText = sText & Left(aResult(iRow, iColumn) & Space(25), 20)
      Next
      LogFileWrite(sText)
    Next
  End If
  Call LogfileWrite(" ")
  Call LogfileWrite(" ")
End Sub

Related Topics

Command: SQLiteAddExtension | Command: SQLiteClose | Command: SQLiteQuery

Was this information helpful?