8000 Issue when using a SQLite database and the DATABASE_URL env var · Issue #23527 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Issue when using a SQLite database and the DATABASE_URL env var #23527
Closed
@javiereguiluz

Description

@javiereguiluz
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 in sqlite:///(database name)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0