Re: connecting to PostgreSQL database

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Mon, 17 Jul 2006 09:04:34 +0200


Hi Roger,

On Sat, 2006-07-15 at 12:14 -0230, Roger Mason wrote:
> Hello,
>
> Does anyone have an example of how to connect to a PostgreSQL
> database from root?
>
> I have seen the examples in the tutorials but they are for MySQL and
> Oracle.

The SQL database interface of ROOT uses the plug-in architecture. Hence, if you have the appropriate plug-in and setting in your rootrc file, all you need to do is

  TSQLServer* dbms = TSQLServer::Connect("<dbms>://<host>[:port][/<database>]");

In your case, using PostgreSQL you need to specify `pgsql' for `<dbms>', that is

  TSQLServer* dbms = TSQLServer::Connect("pgsql://127.0.0.1/test");

Yours,

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Mon Jul 17 2006 - 09:08:29 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:00 MET