Posted on August 14th, 2009 by linux
In PostgreSQL database it is possible to save / export and results of a database query to a simple text file. By default all query result are displayed on the screen. This default behavior can be overwritten by \o command:
postresql=> \o /path/to/your/text/file.txt
postresql=> postgresql query ( here place your query )
postresql=> \o ( set [...]
Filed under: Database, Linux | Comments Off
Posted on July 24th, 2008 by linux
This error message took me lots of effort and time to solve it. The problem is that before storing binary data strings in the postgresql database the binary strings need to be escaped before storing them. There is on the google available subroutine for per which is doing this job. It is called escape_bytea. Anyway [...]
Filed under: Administration, Database, Debian, Perl | No Comments »
Posted on February 1st, 2008 by linux
Simple perl to postgresql examples:
#!/usr/bin/perl
#load perl postgresql module
use DBI;
$postgresql_database=yourpostgresdatabase;
$postgresql_user=yourpostgresuser;
$postgresql_password=yourpostgrespass;
$postgresql_host=localhost;
# connect to perl to postgresql database
my $dbh = DBI->connect(”DBI:Pg:dbname=$postgresql_database;
host=$postgresql_host”, “$postgresql_user”, “$postgresql_password”);
# EXAMPLE PERL and POSTGRESQL
# CREATE TABLE EXAMPLE
$sth = $dbh->prepare(”CREATE TABLE perl_postgres
( language varchar(40), version integer);”);
$sth->execute();
# EXAMPLE PERL and POSTGRESQL
# INSERT DATA INTO TABLE
$dbh->do(”INSERT INTO perl_postgres(language, version)
VALUES (?, ?)”, undef, (’perl’, 5)) or die (”Cannot INSERT”);
# [...]
Filed under: Administration, Database, Linux, Perl | No Comments »