CodeIgniter Forums
SQLite in memory problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: SQLite in memory problem (/showthread.php?tid=241)



SQLite in memory problem - LearningCI - 11-13-2014

Hello, I'm setting CodeIgniter with SQLite in memory DB for unit testing but not working.
This is my configuration:

PHP Code:
$db['test']['hostname'] = '';
$db['test']['username'] = '';
$db['test']['password'] = '';
$db['test']['database'] = ':memory:';
$db['test']['dbdriver'] = 'pdo';
$db['test']['dbprefix'] = '';
$db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
$db['test']['cache_on'] = FALSE;
$db['test']['cachedir'] = '';
$db['test']['char_set'] = 'utf8';
$db['test']['dbcollat'] = 'utf8_general_ci';
$db['test']['swap_pre'] = '';
$db['test']['autoinit'] = TRUE;
$db['test']['stricton'] = FALSE

What I'm doing wrong?

Thanks

PD: Sorry for my english


RE: SQLite in memory problem - slax0r - 11-13-2014

"Not working" is hard to debug. Please provide some errors, from display and/or logs, as well as some code that causes the error. Will get help quicker.

Edit: you might want to try to set hostname to ':memory:' and not database.


RE: SQLite in memory problem - LearningCI - 11-13-2014

(11-13-2014, 08:39 AM)slax0r Wrote: "Not working" is hard to debug. Please provide some errors, from display and/or logs, as well as some code that causes the error. Will get help quicker.

Edit: you might want to try to set hostname to ':memory:' and not database.

I open php files with navigator, where is the error log files? And it's showing nothing, entire page in blank...
The console return:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

And I tried with changing :memory: to hostname and return:
GET http://localhost/xxx/run_tests 500 (Internal Server Error)
Thanks!


RE: SQLite in memory problem - Rufnex - 11-13-2014

Try some settings that point you to your sqllite db (never tried it but could work Wink

Code:
$db['default']['hostname'] = 'sqlite:......../db/app.sqlite';
or
$db['default']['database'] = 'db/db.sqlite.';



RE: SQLite in memory problem - LearningCI - 11-13-2014

(11-13-2014, 11:23 AM)Rufnex Wrote: Try some settings that point you to your sqllite db (never tried it but could work Wink

Code:
$db['default']['hostname'] = 'sqlite:......../db/app.sqlite';
or
$db['default']['database'] = 'db/db.sqlite.';

Hello! But I wanted to create a database in memory, not in a file. It is to run tests. Thanks!


RE: SQLite in memory problem - slax0r - 11-13-2014

(11-13-2014, 10:43 AM)LearningCI Wrote:
(11-13-2014, 08:39 AM)slax0r Wrote: "Not working" is hard to debug. Please provide some errors, from display and/or logs, as well as some code that causes the error. Will get help quicker.

Edit: you might want to try to set hostname to ':memory:' and not database.

I open php files with navigator, where is the error log files? And it's showing nothing, entire page in blank...
The console return:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

And I tried with changing :memory: to hostname and return:
GET http://localhost/xxx/run_tests 500 (Internal Server Error)
Thanks!

In application/config/config.php set log_threshold to 4, then you can find log files in application/logs/ directory.

Also make sure that display_errors is turned on, and error_reporting is set to E_ALL.


RE: SQLite in memory problem - LearningCI - 11-13-2014

(11-13-2014, 01:13 PM)slax0r Wrote:
(11-13-2014, 10:43 AM)LearningCI Wrote:
(11-13-2014, 08:39 AM)slax0r Wrote: "Not working" is hard to debug. Please provide some errors, from display and/or logs, as well as some code that causes the error. Will get help quicker.

Edit: you might want to try to set hostname to ':memory:' and not database.

I open php files with navigator, where is the error log files? And it's showing nothing, entire page in blank...
The console return:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

And I tried with changing :memory: to hostname and return:
GET http://localhost/xxx/run_tests 500 (Internal Server Error)
Thanks!

In application/config/config.php set log_threshold to 4, then you can find log files in application/logs/ directory.

Also make sure that display_errors is turned on, and error_reporting is set to E_ALL.


Oh my God! Thank you very much! I can see the error log on browser! Big Grin

PHP Code:
Fatal errorUncaught exception 'PDOException' with message 'could not find driver' in /var/www/proyec/system/database/drivers/pdo/pdo_driver.php:114 Stack trace#0 /var/www/proyec/system/database/drivers/pdo/pdo_driver.php(114): PDO->__construct(':memory:', '', '', Array) #1 /var/www/proyec/system/database/DB_driver.php(115): CI_DB_pdo_driver->db_pconnect() #2 /var/www/proyec/system/database/DB.php(148): CI_DB_driver->initialize() #3 /var/www/proyec/system/core/Loader.php(346): DB('', NULL) #4 /var/www/proyec/system/core/Loader.php(1171): CI_Loader->database() #5 /var/www/proyec/system/core/Loader.php(152): CI_Loader->_ci_autoloader() #6 /var/www/proyec/system/core/Controller.php(51): CI_Loader->initialize() #7 /var/www/proyec/application/controllers/welcome.php(23): CI_Controller->__construct() #8 /var/www/proyec/system/core/CodeIgniter.php(308): Welcome->__construct() #9 /var/www/proyec/index.php(203): require_once('/var/www/picon/...') #10 {main} thrown in /var/www/proyec/system/database/drivers/pdo/pdo_driver.php on line 114 

And I have installed php5-sqlite on my Linux.
It's my first project with CI, sorry if its a silly mistake


RE: SQLite in memory problem - slax0r - 11-14-2014

No problem at all.


RE: SQLite in memory problem - Chroma - 11-14-2014

Did you solve your problem?


RE: SQLite in memory problem - LearningCI - 11-14-2014

Solved!
Change the hostname from ':memory:' to 'sqlite::memory:' its worked for me!

PHP Code:
$db['test']['hostname'] = 'sqlite::memory:';
$db['test']['username'] = '';
$db['test']['password'] = '';
$db['test']['database'] = '';
$db['test']['dbdriver'] = 'pdo';
$db['test']['dbprefix'] = '';
$db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
$db['test']['cache_on'] = FALSE;
$db['test']['cachedir'] = '';
$db['test']['char_set'] = 'utf8';
$db['test']['dbcollat'] = 'utf8_general_ci';
$db['test']['swap_pre'] = '';
$db['test']['autoinit'] = TRUE;
$db['test']['stricton'] = FALSE

Thanks for all! Smile