Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: SQLite.

SQLite: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
== Configuring Moodle for SQLite ==
== Configuring Moodle for SQLite ==


In Moodle 2.2.4 (Build: 20120706), you need to set the following parameters. It will work if you don't set the null values, but you'll get notices if you set PHP debug level to high.
Following is for Moodle 2.2.4 (Build: 20120706). You need to set the following parameters. It will work if you don't set the null values, but you'll get notices if you set PHP debug level to high.
$CFG->dbtype= 'sqlite3';
$CFG->dbtype= 'sqlite3';
$CFG->dblibrary= 'pdo';
$CFG->dblibrary= 'pdo';
Line 12: Line 12:
$CFG->dbuser= null;
$CFG->dbuser= null;
$CFG->dbpass= null;
$CFG->dbpass= null;
$CFG->dbprefix= 'mdl_';
$CFG->dbprefix= ''; // any prefix (e.g. 'mdl') is ignored, therefore don't use it, because it upsets 3rd party modules
$CFG->dboptions= array();
$CFG->dboptions= array();


It needs to be fixed in 2.2.4. Whe installing, you get:
Then you need to fix lib/ddl/sqlite_sql_generator.php. Copy definitions of functions getCreateTempTableSQL($xmldb_table) and getDropTempTableSQL($xmldb_table) from lib/ddl/postgres_sql_generator.php.
Fatal error: Class sqlite_sql_generator contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (sql_generator::getCreateTempTableSQL, sql_generator::getDropTempTableSQL) in /var/www/html/elearning/lib/ddl/sqlite_sql_generator.php on line 458
 
Call Stack
Then installation works fine; however, it dies after installed, saying 'PHP catchable fatal error'. Let's investigate:
# Time Memory Function Location
cd <moodledata>
1 0.1071 318616 {main}( ) ../index.php:0
ll *sq*
2 0.3405 17675936 install_core( ???, ??? ) ../index.php:174
-rw-r--r-- 1 apache apache 1624064 Oct 23 08:46 _d41d8cd98f00b204e9800998ecf8427e.sq3.php
3 0.3408 17676856 moodle_database->get_manager( ) ../upgradelib.php:1336
# your DB file may have a different name _d41d8cd98f00b204e9800998ecf8427e.sq3.php
# change ownership, so that I can write to the DB. Change group access rights, so that Apache can still write to it.
sudo chown <myusername> _d41d8cd98f00b204e9800998ecf8427e.sq3.php
chmod g+w _d41d8cd98f00b204e9800998ecf8427e.sq3.php
sqlite _d41d8cd98f00b204e9800998ecf8427e.sq3.php
SELECT * FROM config WHERE name LIKE '%debug%';
UPDATE config SET value=32767 WHERE name='debug'; -- This is for PHP 5.4+
.quit
 
Then you get following and more warnings, and it dies:
Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/enrollib.php on line 604
Warning: array_key_exists() expects parameter 2 to be array, boolean given in /var/www/html/elearning/lib/navigationlib.php on line 1069
Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1074
Warning: array_slice() expects parameter 1 to be array, boolean given in /var/www/html/elearning/lib/navigationlib.php on line 1632
Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1635
Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1711
Strict standards: Non-static method PEAR::setErrorHandling() should not be called statically, assuming $this from incompatible context in /var/www/html/elearning/lib/formslib.php on line 64
Strict standards: Non-static method HTML_QuickForm::registerElementType() should not be called statically, assuming $this from incompatible context in /var/www/html/elearning/lib/formslib.php on line 2517
...
Strict standards: Declaration of repository_instance_form::validation() should be compatible with moodleform::validation($data, $files) in /var/www/html/elearning/repository/lib.php on line 1888
Strict standards: Declaration of repository_type_form::validation() should be compatible with moodleform::validation($data, $files) in /var/www/html/elearning/repository/lib.php on line 1990
Strict standards: Declaration of repository_local::get_listing() should be compatible with repository::get_listing($path = '', $page = '') in /var/www/html/elearning/repository/local/lib.php on line 168
Strict standards: Declaration of repository_recent::type_config_form() should be compatible with repository::type_config_form($mform, $classname = 'repository') in /var/www/html/elearning/repository/recent/lib.php on line 236
Strict standards: Declaration of repository_upload::get_listing() should be compatible with repository::get_listing($path = '', $page = '') in /var/www/html/elearning/repository/upload/lib.php on line 204
Strict standards: Declaration of repository_user::get_listing() should be compatible with repository::get_listing($path = '', $page = '') in /var/www/html/elearning/repository/user/lib.php on line 135
Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/enrollib.php on line 160
Strict standards: Declaration of enrol_manual_plugin::get_bulk_operations() should be compatible with enrol_plugin::get_bulk_operations() in /var/www/html/elearning/enrol/manual/lib.php on line 292
...


From old documentation:
From old documentation:

Latest revision as of 22:03, 22 October 2012

SQLite is a serverless SQL database implementation. Moodle has experimental support for it. It is not recommended for production Moodle sites.

Moodle's SQLite driver requires SQLite PDO driver to be present in PHP. It won't work with native (non-PDO) SQL driver in PHP.

Configuring Moodle for SQLite

Following is for Moodle 2.2.4 (Build: 20120706). You need to set the following parameters. It will work if you don't set the null values, but you'll get notices if you set PHP debug level to high. $CFG->dbtype= 'sqlite3'; $CFG->dblibrary= 'pdo'; $CFG->dbhost= null; $CFG->dbname= null; $CFG->dbuser= null; $CFG->dbpass= null; $CFG->dbprefix= ; // any prefix (e.g. 'mdl') is ignored, therefore don't use it, because it upsets 3rd party modules $CFG->dboptions= array();

Then you need to fix lib/ddl/sqlite_sql_generator.php. Copy definitions of functions getCreateTempTableSQL($xmldb_table) and getDropTempTableSQL($xmldb_table) from lib/ddl/postgres_sql_generator.php.

Then installation works fine; however, it dies after installed, saying 'PHP catchable fatal error'. Let's investigate: cd <moodledata> ll *sq* -rw-r--r-- 1 apache apache 1624064 Oct 23 08:46 _d41d8cd98f00b204e9800998ecf8427e.sq3.php

  1. your DB file may have a different name _d41d8cd98f00b204e9800998ecf8427e.sq3.php
  2. change ownership, so that I can write to the DB. Change group access rights, so that Apache can still write to it.

sudo chown <myusername> _d41d8cd98f00b204e9800998ecf8427e.sq3.php chmod g+w _d41d8cd98f00b204e9800998ecf8427e.sq3.php sqlite _d41d8cd98f00b204e9800998ecf8427e.sq3.php SELECT * FROM config WHERE name LIKE '%debug%'; UPDATE config SET value=32767 WHERE name='debug'; -- This is for PHP 5.4+ .quit

Then you get following and more warnings, and it dies: Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/enrollib.php on line 604 Warning: array_key_exists() expects parameter 2 to be array, boolean given in /var/www/html/elearning/lib/navigationlib.php on line 1069 Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1074 Warning: array_slice() expects parameter 1 to be array, boolean given in /var/www/html/elearning/lib/navigationlib.php on line 1632 Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1635 Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/navigationlib.php on line 1711 Strict standards: Non-static method PEAR::setErrorHandling() should not be called statically, assuming $this from incompatible context in /var/www/html/elearning/lib/formslib.php on line 64 Strict standards: Non-static method HTML_QuickForm::registerElementType() should not be called statically, assuming $this from incompatible context in /var/www/html/elearning/lib/formslib.php on line 2517 ... Strict standards: Declaration of repository_instance_form::validation() should be compatible with moodleform::validation($data, $files) in /var/www/html/elearning/repository/lib.php on line 1888 Strict standards: Declaration of repository_type_form::validation() should be compatible with moodleform::validation($data, $files) in /var/www/html/elearning/repository/lib.php on line 1990 Strict standards: Declaration of repository_local::get_listing() should be compatible with repository::get_listing($path = , $page = ) in /var/www/html/elearning/repository/local/lib.php on line 168 Strict standards: Declaration of repository_recent::type_config_form() should be compatible with repository::type_config_form($mform, $classname = 'repository') in /var/www/html/elearning/repository/recent/lib.php on line 236 Strict standards: Declaration of repository_upload::get_listing() should be compatible with repository::get_listing($path = , $page = ) in /var/www/html/elearning/repository/upload/lib.php on line 204

Strict standards: Declaration of repository_user::get_listing() should be compatible with repository::get_listing($path = , $page = ) in /var/www/html/elearning/repository/user/lib.php on line 135

Warning: Invalid argument supplied for foreach() in /var/www/html/elearning/lib/enrollib.php on line 160 Strict standards: Declaration of enrol_manual_plugin::get_bulk_operations() should be compatible with enrol_plugin::get_bulk_operations() in /var/www/html/elearning/enrol/manual/lib.php on line 292 ...

From old documentation: The other database parameters are not used. The database tables are stored in the 'moodledata' file area.

See Also