Redirected from MindTouch Deki/Extensions/MySql
1 of 2 found this page helpful

MySql Database

    Vendor MindTouch
    Type Native
    Categories Database
    Requires MindTouch 1.8.2 or later
    OS Restriction None
    Status Stable
    License Free/Open Source
    SID (service id) sid://mindtouch.com/2007/06/mysql
    Assembly mindtouch.deki.services

    Install Extension

    URL of your MindTouch install (ex: http://www.mindtouch.com)
        

     

    Table of Contents

    Description

    This extension contains functions for displaying data from MySQL databases.

    See also How to add an extension, Using the Extension Dialog, Learn about DekiScript, Extensions Directory.

    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.  The catalog is also referred to database at times.  The catalog contains the tables.
    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)


     


    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.

       

    Was this page helpful?
    Tag page

    Files 1

    FileVersionSizeModified 
    Viewing 15 of 25 comments: view all
    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 07: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 04:40, 14 Aug 2008
    Can anyone expand on the setup instructions for this extension? Such as, how does one properly create a read only user for MySQL? And does this user have to be created in the OS as well? I'm pretty sure thats the source of my problem, of which I receive this error: "Unable to connect to any of the specified MySQL hosts."
    Posted 14:22, 11 Sep 2008
    Is there a way to display BLOBs?
    Posted 05:53, 18 Sep 2008
    Not yet. Support for BLOBs is coming to DekiScript in the future though. No date yet.
    Posted 09:49, 18 Sep 2008
    Sorry if these are stupid questions:
    "db-catalog Config Key" = What is this supposed to be? MySql has its server name, which contains one or more databases within it, each of which contains one or more tables. So what's a catalog?
    "Preference = namespace" = are you trying to associate a particular database within a MySql server here?
    An example or two of connection parameters would also be helpful.
    Posted 17:56, 27 Sep 2008
    The catalog is also the database name. I clarified the description for it.
    Posted 02:06, 28 Sep 2008
    The definition of the return data type is different between specification above and actual-manifest for the MySql extension. Which is correct? I use Deki v8.08.1a on VM.

    function | spec | manifest
    -------------------------------------
    Value | xml | str
    List | xml | list
    Posted 21:50, 23 Nov 2008
    Can I preset a format for the table result of the mysql select???
    Posted 13:47, 8 Apr 2009
    The table is generated automatically based on the columns that are returned. If you need more control over the rendering of the result set, you can use mysql.recordlist to return an array of results and then render it dynamically using DekiScript.
    Posted 14:12, 8 Apr 2009
    Does make nasty sql queries, but BLOB data can be converted to string format instead of being displayed as "System.Byte[]" using:
    CAST(columnName AS CHAR(10) CHARACTER SET utf8)
    Posted 06:51, 7 Jun 2010
    Does any database come with MindTouch install by default? If not, how do I connect MindTouch to a MySql database?
    Posted 17:39, 16 Jan 2011
    Hi, I'm pretty new of dekiwiki scripting and what I'm trying to do is getting a formatted table of data coming out from mysql.
    My query return more than one row, actually hundreds, but finally the List or Map are eather populated by one record.
    Here below a snip of my code. Any help is appreciated.
    var sqlQuery = "select
    date(radpostauth.authdate) as Anno,
    count(username) as Autenticazioni
    FROM radpostauth
    where reply='Access-Accept'
    group by Anno
    order by Anno desc";

    var recordList = [ radsql.RecordList(sqlQuery) ];
    var recordListLenght = #recordList;
    <div>"RecordListLenght :"..recordListLenght</div>

    var recordMap = { query: radsql.Record(sqlQuery) };
    var recordMapLenght = #recordMap;
    <div>"RecordMapLenght :"..recordMapLenght</div>

    both RecordMapLenght and RecordListLenght are equal to 1!
    I'm going crazy about that.
    Please heeelp!! :-)
    Posted 08:46, 25 May 2011
    @racepa radsql.RecordList() already returns a list. don't embed it into another list. radsql.Record() will always just return a single record or nil if none is found
    Posted 10:08, 25 May 2011
    Dear Mind Touch developer i want to know that how can i write the insert query in mind touch what i do is that i go to the Edit page option and then i write the following code that will insert the record into the mysql database table named "user_info" it has 10 columns and i have entered all the 9 columns empty and i want the value of the first column to be the value that i have entered in the textbox this is only for testing how the insert query will work (??) sign in the DB query here indicates that what should i do to get the value of the textbox here in the Dekiscript insert query statement. Kindly help me in this issue.

    <p><script type="text/javascript">/*<![CDATA[*/
    var city;
    function insert()
    {
    city = document.getElementById('txtCity').value;
    alert(city);
    document.getElementById('record').style.visibility = 'visible';
    }
    /*]]>*/</script></p>
    <p><input id="txtCity" name="txtCity" type="text" /></p>
    <div id="record" style="visibility:hidden">
    {{mysql.table(&quot;INSERT into user_info values (??,'','','','','','','','','')&quot;)}}


    </div>
    <p><input ctor="when($this.click) insert()" type="submit" value="Submit" /></p>
    Posted 22:59, 30 May 2011
    Viewing 15 of 25 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by