You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ability to attach additional databases in SQLite:
SQLite provides functionality to allow attaching multiple databases. The syntax to make this attachment is pretty simple: ATTACH DATABASE file_name AS database_name . This allows making queries against SQLite using dot notation in table names.
Why though?
We are using SQL Server as our primary database and tables exist in schemas, so a query could be select * from products.sizes where products.sizes.size in ('sm', 'md') when attempting to create the schema in SQLite this blows up. saying database products not found.
Adding this functionality would allow creating another SQLite database products and tell the connector to attach it via configuration variable when the connection is created.
This would provide a significant improvement in developer experience for people using production databases that support schemas in this way.
Implementation
I have got this working locally and would be glad to implement and submit a PR. My thoughts are to add a new configuration key for database.connections.sqlite maybe attached_databases which would be an array where keys are the alias and values are the database location:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Proposal
Add ability to attach additional databases in SQLite:
SQLite provides functionality to allow attaching multiple databases. The syntax to make this attachment is pretty simple:
ATTACH DATABASE file_name AS database_name
. This allows making queries against SQLite using dot notation in table names.Why though?
We are using SQL Server as our primary database and tables exist in schemas, so a query could be
select * from products.sizes where products.sizes.size in ('sm', 'md')
when attempting to create the schema in SQLite this blows up. saying database products not found.Adding this functionality would allow creating another SQLite database
products
and tell the connector to attach it via configuration variable when the connection is created.This would provide a significant improvement in developer experience for people using production databases that support schemas in this way.
Implementation
I have got this working locally and would be glad to implement and submit a PR. My thoughts are to add a new configuration key for
database.connections.sqlite
maybeattached_databases
which would be an array where keys are the alias and values are the database location:This could be implemented in
Illuminate\Database\Connectors\SQLiteConnector::connect
before returning the connection.Thanks for your consideration.
Beta Was this translation helpful? Give feedback.
All reactions