Logo ROOT   6.08/07
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 #ifndef ROOT_TSQLServer
16 #include "TSQLServer.h"
17 #endif
18 
19 #include <map>
20 #include <string>
21 
22 #if !defined(__CINT__)
23 #include <libpq-fe.h>
24 #else
25 struct PGconn;
26 #endif
27 
28 
29 
30 class TPgSQLServer : public TSQLServer {
31 
32 private:
33  PGconn *fPgSQL; // connection to PgSQL server
34  TString fSrvInfo; // Server info
35  std::map<Int_t,std::string> fOidTypNameMap; // Map of oid to typname, used in GetTableInfo()
36 public:
37  TPgSQLServer(const char *db, const char *uid, const char *pw);
38  ~TPgSQLServer();
39 
40  void Close(Option_t *opt="");
41  TSQLResult *Query(const char *sql);
42  TSQLStatement *Statement(const char *sql, Int_t = 100);
43  Bool_t HasStatement() const;
44  Int_t SelectDataBase(const char *dbname);
45  TSQLResult *GetDataBases(const char *wild = 0);
46  TSQLResult *GetTables(const char *dbname, const char *wild = 0);
47  TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
48  TSQLTableInfo *GetTableInfo(const char* tablename);
49  Int_t CreateDataBase(const char *dbname);
50  Int_t DropDataBase(const char *dbname);
51  Int_t Reload();
52  Int_t Shutdown();
53  const char *ServerInfo();
54 
55  ClassDef(TPgSQLServer,0) // Connection to PgSQL server
56 };
57 
58 #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:137
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:254
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:33
TString fSrvInfo
Definition: TPgSQLServer.h:34
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:35
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 ...