Old content
[+]
Have you ever wished you could retrieve data that is actually in TikiWiki's (or some other) database, but not organized or displayed on-screen in the way you'd like? The SQL plugin can be used to display the results of SELECT queries in a Wiki page. The plugin displays the results of the query in an attractively formatted table.
To use the SQL plugin, you must do the following:
- Use Admin DSN to define the database to be used by the SQL plugin.
- Place a SQL plugin statement in a Wiki page. Please see PluginSQL for instructions.
This page page shows you how to define a DSN so that the SQL plugin can access external data.
This documentation is based on Tikiwiki 1.7.5.
1. On the main Tiki menu, click next to Admin, if necessary, to show the options below this menu item, and choose Admin DSN. You'll see the Admin DSN page, shown here:
2. In the Name area, type a name for the external database you want to use. The name cannot contain spaces.
3. In the DSN area, type a valid DSN. See "DSN Syntax," below.
4. Click Save.
DSN Syntax
To define the DSN, you need to specify:
- Database Type If you are using MySQL, the database type is mysql. If you are using Postgresql, the database type is "pgsql".
- User Supply the name of the user that is qualified to access the database server.
- Password Supply the password for the qualified user.
- Database name Supply the name of the database that contains the desired data.
Here's the syntax:
DSN format: database-type://user:password@host/database-name
Tutorial
In this example we are creating a DSN for the database tiki in host localhost using the user root and the password seldon. The DSN will be named cosa (as in "Cosa Nostra").
Here's how the DSN looks:
mysql://root:seldon@localhost/tiki
When a DSN is created with name foo the permission tiki_p_dsn_foo is automatically created. Only users with that permission can use the DSN to create a query or view the results of a query using that DSN. For more information on the permissions aspect of the SQL plugin, see PluginSQL.
See PluginSQL to learn how to insert SQL queries in Wiki pages.