stevenson.cunanan@gmail.com's avatar

Unit testing with sqlite and multiple databases

Hi,

My system uses 2 databases and my connection. I'm using sqlite in memory for testing 'sqlite_testing' => [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ],

so I have a bunch of tables in db1 and the rest table in db2. When I run phpunit, the encounter an error when fetching from tables in db2. I am currently trying to test my code and I keep getting PDOException: SQLSTATE[HY000]: General error: 1 no such table...

Migration and seeding completes without a problem but db2 always doesn't exist. did I miss anything?

0 likes
2 replies
stevenson.cunanan@gmail.com's avatar

I tried using

DB::connection('master_mysql')->getDatabaseName().'.table' in my query but it just returned :memory:.table If I use mysql driver, the database names are clear and easy; but in sqlite, my understanding is I can't use multiple db's in memory.

Is that correct?

lionslair's avatar

Did you work out how to use multiple sqlite databases?

1 like

Please or to participate in this conversation.