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

Student projects/SQLite: Difference between revisions

From MoodleDocs
(Shifted to dev docs)
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
<p class="note">'''Note''': This page outlines ideas for the XMLDB/SQLite project. It's a ''specification under construction''! If you have any comments or suggestions, please add them to the [[Talk:Student projects/SQLite|page comments]].''</p>
{{Moved_to_dev_docs}}
 
==Summary==
This project is part of the 2008 edition of Google Summer of Code (GSoC). Mentor: Penny Leach. Student: Andrei Bautu.
 
The objective of this project is to extend Moodle's database support and features. The main working directions established in the proposal are:
* implement SQLite in Moodle database abstraction layer;
* implement a tool which will allow administrators to copy a live Moodle database and switch into 'testing mode' using a SQLite copy of the live database.
 
===SQLite support===
 
Adding support for SQLite in Moodle requires a careful analysis of compatibility between Moodle's database requirements and SQLite's features (e.g. https://docs.moodle.org/en/Development:XMLDB_problems).
 
SQLite supports almost all of the features of SQL92 (see http://www.sqlite.org/omitted.html). Some areas that need special attention are:
* proper settings for Unicode support, long field names, numeric/associative fetches, metadata support;
* incompatible SQL commands (e.g. SQLite does not support MySQL's TRUNCATE because it is not part of standard SQL);
* unsupported SQL commands (SQLite does not support GRANT/REVOKE);
* unsupported SQL keywords (SQLite does not support right and full join);
* security issues (in a misconfigured environment, the SQLite database may be downloaded).
 
A serious limitation of SQLite is the limited ALTER TABLE command. In this case, the general solution for the missing clauses problem consists in replacing the query with a series of queries that will create a second table to replace the original one. This will be done by the database layer.
 
===Testing mode tool===
Using this tool, the live database will be copied to a SQLite testing database. This will allow administrators to experiment in testing mode without performing a backup of the live database or worrying about breaking their live site. The tool will use Moodle's XMLDB to replicate the data from the live database to the test database.
 
==Project timeline==
* April, 14 – May, 25 – develop specification
** discus required functionality with the mentor;
** analyze database incompatibilities and possible solutions;
**collect feedback from the mentor and community.
* May, 26 – June, 22 – SQLite support
** implement SQLite support in Moodle database abstraction layer;
** test and benchmark SQLite support
* June, 23 – July, 31 – Testing mode tool
** implement database migration mechanism;
** provide alternative solutions for non-standard SQL commands in Moodle (if necesary)
* August, 1 – August, 18 – remove reported bugs
* September, 3 – submit code and resource files Google
 
==Completion criteria==
Moodle will allow users to:
* work with SQLite databases;
* use testing mode (i.e. replicate a live database to a SQlite test database)
 
==Moodle installation with SQLite database==
 
Moodle 2.0 offers support for SQLite3 database installations. In this case, no database setup is required. Before starting a Moodle install with a SQLite database be sure to read the [[Installing_Moodle|Installing Moodle]] page for general information.
Focusing on the [[Installing_Moodle#Requirements|Requirements]] section, you will notice that the pdo and pdo_sqlite extensions are required for the (experimental) SQLite 3 database support.
 
The SQLite3 database file will be created during the installation process. By default, the database file will be store in Moodle's data directory (see [[Installing_Moodle#CreatDataDir|Creating the data directory]]). During install, the web server must have write access on the directory where the database file will be stored. After installation, the web server must have read-write access to the database file.
 
The installation process follows the following steps:
# Select the language used during the installation process
# Check your PHP settings
# Confirm the locations of this Moodle installation
#:The default SQLite will use the Moodle's data directory for storing of the database file. The SQLite database file also contains a simple protection mechanism that prevents direct downloads of it. However, as emphasised on the [[Installing_Moodle#CreatDataDir|Creating the data directory]] page, you should do your best to protect the Moodle's data directory (and the SQLite database file) against direct web access.
# Configure the database
## Select the database type (SQLite 3 (PDO))
## Fill in the Host Server (optional)
##:This setting specifies the directory where the database file will be stored. If it is empty or it is "localhost", then Moodle's data directory will be used. Otherwise, this settings will be used. In order to avoid problems, do not use a path relative to the current working directory (e.g. ../datadir); use instead an absolute path (e.g. /home/abautu/datadir or C:\Inetpub\abautu\datadir).
## Fill in a database name, an user and a password (all three are optional)
##:The database name, user and password are used to compute the real name of the database file. The database filename is '''''username''_''database''_''passwordmd5''.sq3.php'''. If the username is empty, then the '''''username_''''' prefix is omitted. This prefix allows databases belonging to the same user to be grouped together in a name-ordered directory listing. The '''''passwordmd5''''' part of the filename offers a simple protection of the password in case the database directory allows web browsing ('''try to avoid this'''). The '''''.php''''' filename extension allows the database file to stop direct web downloads in most server setups ('''don't change it'''). Notice that the file is still a binary SQLite3 compatible database file. This filenaming scheme allows different users to use the same directory for storing database files, and allows a user to have multiple databases with the same name but different passwords.
## Fill in the prefix to use for all table names (optional)
# Checking your environment
# Download a language pack for your Moodle site
# Continue the installation process with the current settings
 
==See also==
 
*[[GSOC/2008]]
*[http://code.google.com/soc/2008/moodle/appinfo.html?csaid=5800332C0A064CB0 XMLDB/SQLite application abstract]
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=88827 How to add sqlite-support?] forum discussion
*[http://tracker.moodle.org/browse/MDL-15635 Database migration utility in Tracker]
*[http://tracker.moodle.org/browse/MDL-15071 SQLite support in Tracker]
*[http://tracker.moodle.org/browse/MDL-15320 PDO patches in Tracker]
*[http://cvs.moodle.org/contrib/patches/sqlite/ SQLite driver and Database migration utility in CVS]
[[Category:Project]]

Latest revision as of 04:02, 15 September 2011

This development related page is now located in the Dev docs.

See the Student projects/SQLite page in the Dev docs.