PrePAN

Sign in to PrePAN

Sql::Textify Run a SQL query and get the result in text format (markdown, html, csv)

Good

Synopsis

    use Sql::Textify 'textify';
    my $text = textify( $sql );

    use Sql::Textify 'textify';
    my $text = textify( $sql, {
        conn => 'dbi:connection:string',
        username => 'username',
        password => 'password',
        format => 'markdown',
    } );

    use Sql::Textify;
    my $t = Sql::Textify->new;
    my $text = $t->textify( $sql );

    use Sql::Textify;
    my $t = Sql::Textify->new(
        conn => 'dbi:connection:string',
        username => 'username',
        password => 'password',
        format => 'markdown',
    );
    my $text = $t->textify( $sql );

Description

This module executes SQL queries and produces a text output (markdown, html, csv, ...). Connection details, username and password can be specified in a C-style comment inside the SQL query or using the constructor:

my $t = new Sql::Textify(
    conn => 'dbi:SQLite:dbname=test.sqlite3',
    username => 'myusername',
    password => 'mypassword',
    format => 'markdown',
    layout => 'table'
);
my $text = $t->textify('select * from gardens');

I couldn't find any module that converts data to markdown so I have written one. I am using a script that makes use of this code everyday because I want do run SQL queries on various dbms at the command line (or using sublime text) and I like to get the result in markdown format or in other text formats.

Comments

This is a fantastic idea :-) I would totally use this! Thank you for writing it. Looking forward to it coming to CPAN.

Please sign up to post a review.