PostgreSQL data dictionary generators for the Confluence Wiki

I am looking for a tool that accepts PostgreSQL tables and displays a data dictionary in wiki format (preferably Confluence). It seems that most of the tools out there require a lot of manual work / several tools to complete this task (IE> SchemaSpy, DB Visual Architect, Confluence plugins to output HTML HTML and convert to Confluence). I am looking for ONE tool that scans my Postgres tables and displays a wiki-friendly data dictionary that will allow smooth maintenance as the database changes without having to update my database and database schema in another tool.

+7
source share
2 answers

There is a Bob Swift Confluence SQL Plugin , which allows you to display the data received from the SQL query on the Confluence page. like a table ... maybe it's worth a look?

Confluence 3.1.x - 4.9.x versions are currently supported.

The plugin is free and can be downloaded from the Atlassian Plugin Exchange: https://plugins.atlassian.com/plugins/org.swift.confluence.sql

Additional information about the plugin can be found here: https://studio.plugins.atlassian.com/wiki/display/SQL/Confluence+SQL+Plugin

+1
source

I think you will have to script it yourself, but it's pretty easy and fun. I will take Python here.

I like the XML-RPC Confluence interface. For this, see http://goo.gl/KCt3z . The remote methods you care about are most likely the login, getPage, setPage and / or updatePage. This skeleton will look like this:

import xmlrpclib server = xmlrpclib.Server(opts.url) conn = server.confluence1 token = conn.login(opts.username, opts.password) page = conn.getPage(token,'PageSpace',page_title) page = page + table page = conn.updatePage(token,page,update_options) 

table Here are the data from the PG tables. We will build it below.

For pulling simple data from PostgreSQL, I most often use psycopg2 (also considering SQLSoup). No matter how you retrieve the data, you will get a list of strings as a dictionary. Part of the database is likely to look like this:

 import psycopg2, psycopg2.extras conn = psycopg2.connect("dbname=reece") cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) cur.execute('SELECT * FROM sometable') rows = cur.fetchall() 

Now you need to format the data. For simple things, print = operations will be performed. For more complex formatting, consider a template engine like jinja2 (http://jinja.pocoo.org/). The rendering code might look like this:

 from jinja2 import Template template = Template(open(template_path).read()) table = template.render( rows = rows ) 

The template_path file will contain a formatting template that might look like this:

 <table> <tr> <th>col header 1</th> <th>col header 2</th> </tr> {% for row in rows|sort -%} <tr> <td>{{row.col1}}</td> <td>{{row.col2}}</td> </tr> {% endfor %} </table> 

Note. Confluence no longer uses default wiki markup. You must write HTML.

Finally, if you want to create a page for all tables, you can look at information_schema, which contains information about the database in the form of tables. For example:

 select table_name from information_schema.tables where table_schema = current_schema(); 
0
source

All Articles