Mojo::Pg

Mojolicious :heart: PostgreSQL

Latest version: 4.28 registry icon
Maintenance score
49
Safety score
100
Popularity score
27
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
4.28 0 0 0 0 0
4.28 0 0 0 0 0
4.27 0 0 0 0 0
4.27 0 0 0 0 0
4.26 0 0 0 0 0
4.26 0 0 0 0 0
4.25 0 0 0 0 0
4.25 0 0 0 0 0
4.24 0 0 0 0 0
4.24 0 0 0 0 0
4.23 0 0 0 0 0
4.23 0 0 0 0 0
4.22 0 0 0 0 0
4.22 0 0 0 0 0
4.21 0 0 0 0 0
4.21 0 0 0 0 0
4.20 0 0 0 0 0
4.20 0 0 0 0 0
4.19 0 0 0 0 0
4.19 0 0 0 0 0
4.18 0 0 0 0 0
4.18 0 0 0 0 0
4.17 0 0 0 0 0
4.17 0 0 0 0 0
4.16 0 0 0 0 0
4.16 0 0 0 0 0
4.15 0 0 0 0 0
4.15 0 0 0 0 0
4.14 0 0 0 0 0
4.14 0 0 0 0 0
4.13 0 0 0 0 0
4.13 0 0 0 0 0
4.12 0 0 0 0 0
4.12 0 0 0 0 0
4.11 0 0 0 0 0
4.11 0 0 0 0 0
4.10 0 0 0 0 0
4.10 0 0 0 0 0
4.09 0 0 0 0 0
4.09 0 0 0 0 0
4.08 0 0 0 0 0
4.08 0 0 0 0 0
4.07 0 0 0 0 0
4.07 0 0 0 0 0
4.06 0 0 0 0 0
4.06 0 0 0 0 0
4.05 0 0 0 0 0
4.05 0 0 0 0 0
4.04 0 0 0 0 0
4.04 0 0 0 0 0
4.03 0 0 0 0 0
4.03 0 0 0 0 0
4.02 0 0 0 0 0
4.02 0 0 0 0 0
4.01 0 0 0 0 0
4.01 0 0 0 0 0
4.0 0 0 0 0 0
4.0 0 0 0 0 0
3.06 0 0 0 0 0
3.06 0 0 0 0 0
3.05 0 0 0 0 0
3.05 0 0 0 0 0
3.04 0 0 0 0 0
3.04 0 0 0 0 0
3.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0 0 0 0 0
2.02 0 0 0 0 0
2.01 0 0 0 0 0
2.01 0 0 0 0 0
2.0 0 0 0 0 0
2.0 0 0 0 0 0
1.17 0 0 0 0 0
1.17 0 0 0 0 0
1.16 0 0 0 0 0
1.16 0 0 0 0 0
1.15 0 0 0 0 0
1.15 0 0 0 0 0
1.14 0 0 0 0 0
1.14 0 0 0 0 0
1.13 0 0 0 0 0
1.13 0 0 0 0 0
1.12 0 0 0 0 0
1.12 0 0 0 0 0
1.11 0 0 0 0 0
1.11 0 0 0 0 0
1.10 0 0 0 0 0
1.10 0 0 0 0 0
1.09 0 0 0 0 0
1.09 0 0 0 0 0
1.08 0 0 0 0 0
1.08 0 0 0 0 0
1.07 0 0 0 0 0
1.07 0 0 0 0 0
1.06 0 0 0 0 0
1.06 0 0 0 0 0
1.05 0 0 0 0 0
1.05 0 0 0 0 0
1.04 0 0 0 0 0
1.04 0 0 0 0 0
1.03 0 0 0 0 0
1.03 0 0 0 0 0
1.02 0 0 0 0 0
1.02 0 0 0 0 0
1.01 0 0 0 0 0
1.01 0 0 0 0 0
1.0 0 0 0 0 0
1.0 0 0 0 0 0
0.11 0 0 0 0 0
0.11 0 0 0 0 0
0.10 0 0 0 0 0
0.10 0 0 0 0 0
0.09 0 0 0 0 0
0.09 0 0 0 0 0
0.08 0 0 0 0 0
0.08 0 0 0 0 0
0.07 0 0 0 0 0
0.07 0 0 0 0 0
0.06 0 0 0 0 0
0.06 0 0 0 0 0
0.05 0 0 0 0 0
0.05 0 0 0 0 0
0.04 0 0 0 0 0
0.04 0 0 0 0 0
0.03 0 0 0 0 0
0.03 0 0 0 0 0
0.02 0 0 0 0 0
0.02 0 0 0 0 0
0.01 0 0 0 0 0
0.01 0 0 0 0 0

Stability
Latest release:

4.28 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Artistic-2.0   -   Artistic License 2.0

Not a wildcard

Not proprietary

OSI Compliant



Mojo::Pg

A tiny wrapper around DBD::Pg that makes PostgreSQL a lot of fun to use with the Mojolicious real-time web framework.

use Mojolicious::Lite -signatures;
use Mojo::Pg;

helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };

# Use migrations to create a table during startup
app->pg->migrations->from_data->migrate;

get '/' => sub ($c) {

  my $db = $c->pg->db;
  my $ip = $c->tx->remote_address;

  # Store information about current visitor blocking
  $db->query('INSERT INTO visitors VALUES (NOW(), ?)', $ip);

  # Retrieve information about previous visitors non-blocking
  $db->query('SELECT * FROM visitors LIMIT 50' => sub ($db, $err, $results) {

    return $c->reply->exception($err) if $err;

    $c->render(json => $results->hashes->to_array);
  });
};

app->start;
__DATA__

@@ migrations
-- 1 up
CREATE TABLE visitors (at TIMESTAMP WITH TIME ZONE, ip TEXT);
-- 1 down
DROP TABLE visitors;

Installation

All you need is a one-liner, it takes less than a minute.

$ curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Mojo::Pg

We recommend the use of a Perlbrew environment.

Want to know more?

Take a look at our excellent documentation!