MySql

This extension contains functions for displaying data from MySQL databases.  Related Links: Extension Overview, DekiScript Overview, Extension Demos.

Assembly: mindtouch.deki.services
SID: sid://mindtouch.com/2007/06/mysql

This service requires Deki Wiki 1.8.2 or later.

To enable this extension, follow these steps:

  1. Go to Service management in the Control Panel of your wiki.
  2. Under Add Service, click on Local, and select type Extension.
  3. Enter a description and the extension SID: sid://mindtouch.com/2007/06/mysql
  4. Add any additional configuration settings that are required by the extension (see below).
  5. Click on add service.

Configuration:

Before the MySql service can be used, it must be configured with the access information to the database.

Config Key Description
db-server IP/hostname of the MySql server
db-port Optional.  MySql server port (default: 3306)
db-catalog Database catalog name
db-user User name (IMPORTANT: make sure user has read-only access!)
db-password Password for user
db-options Optional.  Custom options string that is passed in when connecting to the database

If you need to configure multiple databases for the same wiki, register this extension once for each database.  Use the following preference to specify a unique namespace value for each registration.  Invoke the service using this value instead of mysql.  For example, if you set namespace=mydb1, you would invoke the service with mydb1.table("...") instead of mysql.table("...").

Preference Description
namespace Specifies a custom namespace (default: mysql)

Functions:


MySql.Table(query : str) : xml

Show results of a SELECT query in a sortable table.

Parameters:

Name Type Description
query str SELECT query.

Samples:

     Output

To embed a SELECT query that displays a list of all users in the users table:

{{ mysql.table("SELECT user_name as Name, user_email as Email FROM users")  }} 
./MySql1.JPG

MySql.Value(query : str) : xml

Show single value from a SELECT query. (New in 1.8.3)

Parameters:

Name Type Description
query str SELECT query.

    


MySql.List(query : str, column : str) : xml

Collect rows as a list from a SELECT query. (New in 1.8.3)

Parameters:

Name Type Description
query str SELECT query.
column str Optional. Column name (default: first column)

    


MySql.Record(query : str) : map

Collect all columns from a SELECT query. (New in 8.05)

Parameters:

Name Type Description
query str SELECT query.

    


MySql.RecordList(query : str) : list

Collect all columns and all rows from a SELECT query. (New in 8.05)

Parameters:

Name Type Description
query str SELECT query.

   

    

Tag page
Viewing 12 of 12 comments: view all
NOTE: the "dp-catalog" should be "db-catalog". I was getting a failure until I canged the configuration value. I am using the default port, but I assume that should say db as well.
Posted 15:27, 14 Oct 2007
Yep, you're correct. I fixed it. Thanks!
Posted 09:04, 15 Oct 2007
how difficult would it be to add a function that would push data entered into a form into the mysql database
I would like to have a dynmic table on a wiki page to which data can be added and deleted.
Posted 07:14, 20 Oct 2007
can you also post examples of this:

db-options Optional. Custom options string that is passed in when connecting to the database
Posted 17:13, 26 Oct 2007
For example, we use commonly the following options string:
pooling=true; Connection Timeout=5; Protocol=socket; Min Pool Size=2; Max Pool Size=50; Connection Reset=false;character set=utf8
Posted 20:18, 26 Oct 2007
I'd like to know if comment #3 can be done?

It would be great to allow the user to add data to mysql directly on the wiki page.

"how difficult would it be to add a function that would push data entered into a form into the mysql database
I would like to have a dynmic table on a wiki page to which data can be added and deleted."
Posted 14:25, 7 Jan 2008
Add another to the list for #3.

That would be a great feature.
Posted 18:05, 10 Feb 2008
We're working on adding "write-back" capability, but it's still in the early design proces. It's important we get this right without creating a security hole.
Posted 06:55, 11 Feb 2008
I'd also add my vote for this bidirectional data exchange feature. Perhaps looking at the architecture of the excellent but not very actively developed Ruby on Rails "database" wiki InformL ( http://informl.folklogic.net ) might help in the design process?
Posted 03:23, 18 Mar 2008
I just checked out the screencast and demo of Informl and that is pretty cool. If forms and sortable data tables could be combined with Deki Wiki, that would make a killer application. It would replace a number of basic Excel spreadsheets and Access databases in my organization because they would be easy to create and maintain, as well as, easily be accessed and shared amongst multiple users. this would be much more useful than the ADO.NET extension, because it not only allows viewing the data in a sortable table but also allows for creating and editing data. edited 16:23, 18 Mar 2008
Posted 15:44, 18 Mar 2008
Writeable forms would be incredibly useful. I tried to use the MySQL extension to list glossary pages (glossary/word) from the wikidb catalog but of course the html tags were also displayed in the table. I had hoped the function would either remove html tags in the data or use them intelligently but this was naive perhaps.
Posted 15:31, 5 Apr 2008
Since my company uses a custom made issue tracker, I was hoping I could use this extension to retrieve the issue list directly from mysql. Of course this works just fine, except I want something more. =)

I wanted to transform the ID-field to a link that would point to our issue tracker, I did a really fancy MySQL query for it and when I tested it in mysql client, it worked perfectly. However when I tried it in this extension, the link part only returned the text "System.Byte[]". It did fetch all the rows correctly and render the table, but the ID part was not working for some reason. Any idea what might cause that?

The query I was using was similar to this: (yes, I did escape the double quotes when I put it inside mysql.Table())
SELECT CONCAT_WS('', '<a href="http://url.to.issue.tracker/issue/', issue_id, '">', issue_id, '</a>') AS `ID`, issue_title AS `Title` FROM issues WHERE project = 1337
Posted 12:40, 14 Aug 2008
Viewing 12 of 12 comments: view all
You must login to post a comment.