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.
- PostgreSQL (
postgres
) - MySQL (
mysql
)
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 queriesTEXT
database connection string
SELECT dblite_open('postgres', 'mydb', 'postgres://...')
Scalar function that checks if an opened database can be connected to.
Params:
TEXT
database name (string used as second param todb_open
)
SELECT dblite_ping('mydb')
Scalar function that executes a SQL statement without any results.
Params:
TEXT
database nameTEXT
SQL to execute
SELECT dblite_exec('mydb', 'DROP TABLE ...')
Table-valued function that executes a SQL statement and returns the results.
Params:
TEXT
database nameTEXT
SQL to execute
SELECT * FROM dblite_query('mydb', 'SELECT * FROM ...')
Scalar function that closes a database and deregisters it.
Params:
TEXT
database name
SELECT dblite_close('mydb')