Git Product home page Git Product logo

picocms-mysqllist's Introduction

PicoCMS plugin : MySQLList

Fetch data from mysqlDB. Put fields values into markdown.

Motivations

Adding database connection for the great flat file CMS Pico sound weird! Yes it is. The goal is to use pico as a base to monitor a MySQL database and show some key values. It will be completed with a MySQLGraph plugin and a GETFromAPI plugin.

Install

Copy the MySQLListPlugin.php and the MySQLConfig.php files into the plugins folder.

Config

First, config your database access in the MySQLConfig.php :

return array(
    'db1'=>array ( // database settings name for the plugin 
        'host' => 'localhost', //database host
        'username' => 'admin', //database username
        'password' => 'passwd1', //database password
        'db_name' => 'db1_name') //database name
);


You can add several database in this file. If you also use the MySQLGraph plugin, you can share the conf file : put MySQLListPlugin.php, MySQLGraphPlugin.php and a MySQLConfig.php files in the root plugin folder.

Then, you should write queries, and give them names in the Pico's config :

mysql_source:
 db1:                             # First database config name
  #query_name: "SQL Query, SELECT only"
  select_users: "select * from user limit 2"
  select_android_user: "select * from user  where is_android = false limit 3"

For queries delimitation, only use ", not `, since it can be use in the SQL query.

Finally, use those queries in your markdown file :

  • query : the name of the query used as it is in the Pico's conf file.
  • row : the markdown you want to insert in your file for each row of the query result. Use { and } to put your query column name.

For a list:

[db_source query="select_users" row=" + {id} *email* : {email}" ]

Or a table:

| id | email |
|----|:------|
[db_source query="select_users" row=" | {id} | {email} |" ]

picocms-mysqllist's People

Contributors

psic avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.