dblite
SQLite extension for accessing other SQL databases, in SQLite.
Similar to how Postgres Foreign Data Wrappers enable access to other databases in PostgreSQL, this project is a way to access "foreign" SQL databases in SQLite.
It compiles to a run-time loadable extension, using riyaz-ali/sqlite.
It uses database/sql, so should be compatible with any database that implements a driver.
(Currently) Supported Databases
- PostgreSQL (
postgres)
- MySQL (
mysql)
Available Functions
dblite_open
Scalar function that registers a database by name for use in later queries.
Params:
TEXT driver name (see supported databases above)
TEXT give a name to the database connection, referenced in subsequent queries
TEXT database connection string
SELECT dblite_open('postgres', 'mydb', 'postgres://...')
dblite_ping
Scalar function that checks if an opened database can be connected to.
Params:
TEXT database name (string used as second param to db_open)
SELECT dblite_ping('mydb')
dblite_exec
Scalar function that executes a SQL statement without any results.
Params:
TEXT database name
TEXT SQL to execute
SELECT dblite_exec('mydb', 'DROP TABLE ...')
dblite_query
Table-valued function that executes a SQL statement and returns the results.
Params:
TEXT database name
TEXT SQL to execute
SELECT * FROM dblite_query('mydb', 'SELECT * FROM ...')
dblite_close
Scalar function that closes a database and deregisters it.
Params:
TEXT database name
SELECT dblite_close('mydb')