SQLite Module
#sqlite.open sqlitedb sqlite.open(string filename)

Open an SQLite database file and return a handle to the database. If the file does not exist, it will be created for you.

Example: db = sqlite.open("mydatabase.db");
#sqlite.close sqlite.close(sqlitedb db)

Close an opened SQLite database.

Example: sqlite.close(db);
#sqlite.execute table sqlite.execute(sqlitedb db, string query)

Run a query on an opened SQLite database. Returns a table of results where each result is a table of field/value pairs. For example, pretend database table 'people' contains the fields 'id', 'first_name', and 'last_name'. A query to grab known people might look like this:

Example: db = sqlite.open("examples.db"); results = sqlite.execute(db, "SELECT * from `people`"); print("Results:\nID\tFirst Name\tLast Name"); for id,result in pairs(results) do printf("\t%d\t%s\t%s\n", result.id, result.first_name, result.last_name); end Example output: Results: ID First Name Last Name 1 John Smith 2 Jane Doe

Page last updated at 2018-09-25 20:48:36


Copyright 2018