0

I am trying to connect to sqlite database file with Doctrine DBAL.

<?php
use Doctrine\DBAL\DriverManager;
require_once 'bootstrap.php';
$connectionParams = [
    'url' => 'sqlite:///crawls.db',
];
$conn = DriverManager::getConnection($connectionParams);

But when I try to execute sql code it says that table is not exist (of course I checked manually and it is there).

$conn->exec('SELECT * FROM crawl_item');

outputs

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 no such table: crawl_item' in /home/px/Documents/phpcrawler/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:57
Stack trace:...

May be this output can be helpful

 var_dump($conn->connect());
 var_dump($conn->getDatabase());

 bool(true)
 NULL

1 Answers1

1

If you look at the AbstractSQLiteDriver::_constructPdoDsn() method you will see that the parameter is 'path':

$connectionParams = [
    [
        'driver' => 'pdo_sqlite',
        'path' => '../products.db'
    ]
);

$conn = DriverManager::getConnection($connectionParams);

greetings, thomas

Thomas Eimers
  • 395
  • 5
  • 5