-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: URL is not defined! #27
Comments
The problem also happens when I set DB_DATABASE to configuration for other database (e.g. mariadb). |
this is not libsql related, you just doing it wrong, see: https://laravel.com/docs/11.x/database#sqlite-configuration use: *make sure the |
@elymatos you can see the TestCase.php how to configure if the readme is not enough. |
Thanks for responses. I'm sorry if the questions seem so fool, but I really want to understand what is going on (I tried to open a issue as "ask a question" and not a "bug", but the page is not working). DatabaseManager:
LibSQLDriverServiceProvider:
So, following the trace it is possible to see that the driver for my default connection (mariadb) is changed to (sqlite). So LibSQLDatabase is constructed with wrong config (all the variables are from my mariadb connection, but the driver is sqlite). As the config has no "URL" configured, I get the error above. I just need to know if this driver only allows to work with SQLite or if it is possible to work with multiple databases (with different drivers). In the last case, what is necessary to change (if something) to make this work. |
Thank you @elymatos for your explanations, I am try to test following your traces to make sure and here is the test: <?php
it('uses the default connection factory for non-libsql drivers', function () {
$dbManager = $this->app->make(Illuminate\Database\DatabaseManager::class);
// Set the default connection to mariadb
config(['database.default' => 'mariadb']);
// Add mariadb connection configuration
config([
'database.connections.mariadb' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
]
]);
$connection = $dbManager->connection('mariadb');
expect($connection->getConfig('driver'))->toBe('mysql');
expect($connection)->toBeInstanceOf(\Illuminate\Database\MySqlConnection::class);
})->group('ConnectDifferentDatabaseDriver', 'FeatureTest');
it('uses the libsql connection factory for libsql driver', function () {
$dbManager = $this->app->make(Illuminate\Database\DatabaseManager::class);
// Set the default connection to libsql
config(['database.default' => 'libsql']);
// Add libsql connection configuration
config([
'database.connections.libsql' => [
'driver' => 'libsql',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'url' => env('DB_SYNC_URL', ''),
'authToken' => env('DB_AUTH_TOKEN', ''),
'syncInterval' => env('DB_SYNC_INTERVAL', 5),
'read_your_writes' => env('DB_READ_YOUR_WRITES', true),
'encryptionKey' => env('DB_ENCRYPTION_KEY', ''),
]
]);
$connection = $dbManager->connection('libsql');
expect($connection->getConfig('driver'))->toBe('libsql');
expect($connection)->toBeInstanceOf(Turso\Driver\Laravel\Database\LibSQLConnection::class);
})->group('ConnectDifferentDatabaseDriver', 'FeatureTest'); The LibSQL driver's service provider replaces the When accessing a non-default (if the default is DB::connection('mariadb')->table('albums')->get(); or when the default connection is DB::connection('libsql')->table('albums')->get(); Please correct me if I am wrong. |
What happened?
Hi!
I'm trying to access a local database. Following the instructions, I've ignores the other variables at .env and I just defined
DB_DATABASE=database.chinook
How to reproduce the bug
I create a minimal script
print_r(DB::table('albums')->get());
But I'm receiving:
As far I understood URL is necessary just to remote connection.
What is necessary to configure for local connection?
Tks,
Ely
Package Version
last (from composer)
PHP Version
8.3
Laravel Version
11.0
Which operating systems does with happen with?
Linux
Notes
No response
The text was updated successfully, but these errors were encountered: