Manual:SQLite/cs



Účelem této stránky je shromažďovat informace a zkušenosti s provozováním MediaWiki na SQLite.

MediaWiki podporuje SQLite od 1.17, ale mějte na paměti, že se jedná o podporu druhé třídy a pravděpodobně narazíte na nějaké chyby. Nejčastěji používaná databáze s MediaWiki je. Seznam problémů naleznete v Phabricatoru. MediaWiki vyžaduje SQLite nebo novější. Podpora SQLite pomocí rozšíření, která provádějí změny v databázi, je různá.



Je SQLite dobrou volbou pro MediaWiki?
Existují dvě důležitá upozornění na používání SQLite pro MediaWiki. Za prvé, zatímco mnoho rozšíření podporuje SQLite, existují některá populární rozšíření, která jej dodnes nepodporují. Za druhé, SQLite se neškáluje nad rámec jednoho serveru. V případě, že se vaše wiki rozroste a bude mít mnoho souběžných uživatelů a velké množství obsahu, bylo by lepší použít databázový systém, který podporuje model primární repliky, jako je MySQL. V důsledku toho, pokud vaše wiki může záviset na používání těchto rozšíření nebo může potřebovat použít primární replikovaný databázový systém, je nejlepší použít pro vaši wiki databázi MySQL. Rozhodnutí použít SQLite, MySQL nebo jiný databázový systém by mělo být v ideálním případě učiněno před vytvořením wiki, protože je obtížné převést z databáze SQLite na databázi MySQL, jakmile začnete používat svou wiki.

About SQLite
SQLite is an open-source database library released into public domain. Unlike client-server database management systems, the SQLite library is linked into PHP and thus becomes an integral part of the server process. MediaWiki uses SQLite's functionality through simple function calls, which reduces latency in database access as function calls are more efficient than inter-process communication.

Using SQLite as database backend for MediaWiki has its own pros and cons:


 * Pros


 * You don't have to install and maintain a standalone database server such as MySQL; this significantly reduces efforts spent on administration and removes some points of failure.
 * The former also means that SQLite is much more suitable for portable MediaWiki installs running from a USB stick.
 * You are not restricted by artificial database limitations on shared hosts.
 * The entire database is stored as a single cross-platform file, simplifying backups and migration.


 * Cons


 * SQLite is not that scalable, so if you have a large and popular wiki, you should use MySQL.
 * Although SQLite has its own search engine, it's not supported by more advanced solutions such as Lucene.
 * Several extensions are known to have database update or installation issues with SQLite: AbuseFilter, Echo, Flow, and LiquidThreads.

SQLite installation
At least SQLite version + is required. Also, in order to use full text search, SQLite must be compiled with FTS3 module enabled (most builds have it out of the box these days). SQLite3 works via PHP's PDO functions.

You should uncomment the following line in your Anything outside of the webroot should be safe; it's good to keep it nearby. Or, if you feel like it, you could put it in the web root somewhere and make sure to use webserver config to deny access to it.
 * To install SQLite3 on a Debian or Ubuntu based system, use.
 * Windows binaries from php.net are OK.
 * The PHP PDO SQLite module needs to be loaded.
 * Where should you put the SQLite database itself? The default path seems to be $IP/../data/$dbname.sqlite.

Installing MediaWiki on SQLite backend

 * If SQLite module for PHP is properly installed, MediaWiki installer should offer you an option to use SQLite.
 * If you enter nothing into the "SQLite data directory" field, your will be left empty, which corresponds to   directory in the parent of the document root, however this directory might be different for web scripts and maintenance scripts run from command line, so specifying it explicitly is recommended.

Search engine
Search capabilities for SQLite backend was introduced in MediaWiki 1.16. They require SQLite with FTS3 module compiled-in, which is usually present in most modern builds. If you've recently updated your SQLite support to a version that includes FTS3, run the updater as if you're upgrading MediaWiki. After the updater script created the search index table, populate it with. Same applies to switches back to environments without FTS3: re-running the updater will downgrade the table to avoid SQL errors.

Unable to access the database on the terminal
To get command-line access to the database, type on the terminal:

sqlite3 /var/data/database_name.sqlite

replacing  with the directory that was set as the "SQLite data directory" during the installation process. Alternatively, look for inside.

This can be tricky if you are not experienced about SQLite and run  - because this will open a completely different database (creating it if it doesn't exist) since SQLite interprets the argument not as a system-wide database name, but instead as the file name that contains the db.

Problems
Bugs should be reported to Wikimedia's bug tracker. First check if your problem was already reported - check the dependencies of tag and use search. If you can't find your problem, create a new issue. In any case please take some steps to make your bug easy to find and track: mention SQLite in its summary field and make it have the project tag SQLite.

Performance Tips

 * If possible, ensure you have the APCu php extension installed and set to CACHE_ACCEL. If no cache is present, MediaWiki will use the database as a cache backend, which can lead to write contention. On Sqlite this can significantly slow down your wiki.
 * Make sure your SQLite database is in WAL mode. This can have a major impact on performance when people are viewing and editing your site at the same time. You can do this by using the sqlite command line tool to open the DB, and run the command.