Database support for ODBC and SQLite3

Liberty BASIC v5.0 comes with support for connecting to and interacting with ODBC and SQLite3 databases.

In order to use ODBC databases you must have access to running instance of an ODBC database and you must specify on ODBC data source on the the computer on which you are running Liberty BASIC v5.0.  In the case of SQLite 3 databases Liberty BASIC v5.0 comes with the SQLite3 drivers, so you only need the actual database tables files or you can create your own easily.

Example SQLite 3 program

  'Retrieve some rows from SQLite database table and print them out.
  print "Connecting to database."
  sqliteconnect #records, "Records.db"

  'Query the database.

  query$ = "select * from Payables"

  #records execute(query$)
  'Test the accessor to see if there are any result rows

  if #records hasanswer() then

    for x = 1 to #records rowcount()
      print #records nextrow$(",")
    next x
  end if
  'Disconnect from the database.

  #records disconnect()
  print "Done."
  end

Database Accessor Methods

#handle EXECUTE(expr$) - Execute the SQL query in expr$
#handle DISCONNECT() - Disconnect from the database
#handle HASANSWER() - Return true (nonzero) if there are result rows to read from the last query
#handle NEXTROW$(delimiter$) - Return the next row as a string using delimiter$ to separate each item
#handle ROWCOUNT() - Return the number of unread result rows from the last query
#handle COLUMNNAMES$() - Return a string containing the comma delimited column names from the last query
#handle ISNULL() - Returns zero (or false)
#handle DEBUG$() - Returns the string "SQLite Accessor" or "ODBC Accessor"