-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Description
| Q | A |
|---|---|
| Bug report? | yes |
| Feature request? | no |
| BC Break report? | no |
| RFC? | no |
| Symfony version | - |
As reported in symfony/flex#129, there seems to be a problem parsing the SQLite connection string when using the DSN-syntax in an env var.
How to reproduce
Create a project:
$ composer create symfony/skeleton my-project
$ cd my-project/
$ composer require doctrine
Configure a SQLite database using the same syntax suggested by Flex:
# .env
###> doctrine/doctrine-bundle ###
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
###< doctrine/doctrine-bundle ###Try to create the database:
$ ./bin/console doctrine:database:create
Then you see this error:
Could not create database %kernel.project_dir%/var/data.db for connection named default
An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file
Note that the 3 slashes are correct for a SQLite connection string:
As you can read in Doctrine docs (http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html) the SQLite connection string must have 3 slashes: the first 2 are the same as for others (sqlite://) and the third one is needed to separate the user+host+port from the database name.
In the case of the SQLite, the user+host+port is empty, so the string
sqlite://+(nothing)+/+(database name)results insqlite:///(database name)