Logo ROOT   6.10/09
Reference Guide
TPgSQLServer.h
Go to the documentation of this file.
1 // @(#)root/pgsql:$Id$
2 // Author: g.p.ciceri <gp.ciceri@acm.org> 01/06/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TPgSQLServer
13 #define ROOT_TPgSQLServer
14 
15 #include "TSQLServer.h"
16 
17 #include <map>
18 #include <string>
19 
20 #if !defined(__CINT__)
21 #include <libpq-fe.h>
22 #else
23 struct PGconn;
24 #endif
25 
26 
27 
28 class TPgSQLServer : public TSQLServer {
29 
30 private:
31  PGconn *fPgSQL; // connection to PgSQL server
32  TString fSrvInfo; // Server info
33  std::map<Int_t,std::string> fOidTypNameMap; // Map of oid to typname, used in GetTableInfo()
34 public:
35  TPgSQLServer(const char *db, const char *uid, const char *pw);
36  ~TPgSQLServer();
37 
38  void Close(Option_t *opt="");
39  TSQLResult *Query(const char *sql);
40  TSQLStatement *Statement(const char *sql, Int_t = 100);
41  Bool_t HasStatement() const;
42  Int_t SelectDataBase(const char *dbname);
43  TSQLResult *GetDataBases(const char *wild = 0);
44  TSQLResult *GetTables(const char *dbname, const char *wild = 0);
45  TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
46  TSQLTableInfo *GetTableInfo(const char* tablename);
47  Int_t CreateDataBase(const char *dbname);
48  Int_t DropDataBase(const char *dbname);
49  Int_t Reload();
50  Int_t Shutdown();
51  const char *ServerInfo();
52 
53  ClassDef(TPgSQLServer,0) // Connection to PgSQL server
54 };
55 
56 #endif
Int_t Shutdown()
Shutdown the database server.
const char Option_t
Definition: RtypesCore.h:62
~TPgSQLServer()
Close connection to PgSQL DB server.
Basic string class.
Definition: TString.h:129
TPgSQLServer(const char *db, const char *uid, const char *pw)
Open a connection to a PgSQL DB server.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TSQLResult * Query(const char *sql)
Execute SQL command.
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)
List all columns in specified table in the specified database.
TSQLTableInfo * GetTableInfo(const char *tablename)
Produce TSQLTableInfo.
Int_t DropDataBase(const char *dbname)
Drop (i.e.
#define ClassDef(name, id)
Definition: Rtypes.h:297
TSQLResult * GetDataBases(const char *wild=0)
List all available databases.
TSQLStatement * Statement(const char *sql, Int_t=100)
Produce TPgSQLStatement.
TSQLResult * GetTables(const char *dbname, const char *wild=0)
List all tables in the specified database.
PGconn * fPgSQL
Definition: TPgSQLServer.h:31
TString fSrvInfo
Definition: TPgSQLServer.h:32
void Close(Option_t *opt="")
Close connection to PgSQL DB server.
const char * ServerInfo()
Return server info.
Int_t SelectDataBase(const char *dbname)
Select a database. Returns 0 if successful, non-zero otherwise.
Int_t CreateDataBase(const char *dbname)
Create a database. Returns 0 if successful, non-zero otherwise.
std::map< Int_t, std::string > fOidTypNameMap
Definition: TPgSQLServer.h:33
Int_t Reload()
Reload permission tables.
Bool_t HasStatement() const
PG_VERSION_NUM conveniently only started being #defined at 8.2.3 which is the first version of libpq ...