Local MySQL
The Local Database module provides a simple interface for interacting with SQLite databases. It supports both in-memory and file-based databases, allowing for flexible data storage options.
Constructor
The constructor initializes a new instance of the sql
class, allowing you to specify whether to use an in-memory database or a file-based database.
location
A boolean for an in-memory database (true
), or a string for a file-based database (specifying the database filename without the extension).
Methods
get
get
Returns the SQLite database instance.
query
query
Executes a SQL query with optional parameters.
query
The SQL query to execute.
params
Optional parameters for the SQL query.ms
refresh
refresh
Refreshes the SQLite database connection.
File-Based Example
Here’s how you can use the sql
class to create a database and execute a query:
In-Memory Database Example
To create an in-memory database, simply pass true
to the constructor:
Last updated