Logo ROOT  
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 #include <libpq-fe.h>
21 
22 class TPgSQLServer : public TSQLServer {
23 
24 private:
25  PGconn *fPgSQL{nullptr}; // connection to PgSQL server
26  TString fSrvInfo; // Server info
27  std::map<Int_t,std::string> fOidTypNameMap; // Map of oid to typname, used in GetTableInfo()
28 public:
29  TPgSQLServer(const char *db, const char *uid, const char *pw);
30  ~TPgSQLServer();
31 
32  void Close(Option_t *opt="") final;
33  TSQLResult *Query(const char *sql) final;
34  TSQLStatement *Statement(const char *sql, Int_t = 100) final;
35  Bool_t HasStatement() const final;
36  Int_t SelectDataBase(const char *dbname) final;
37  TSQLResult *GetDataBases(const char *wild = nullptr) final;
38  TSQLResult *GetTables(const char *dbname, const char *wild = nullptr) final;
39  TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = nullptr) final;
40  TSQLTableInfo *GetTableInfo(const char* tablename) final;
41  Int_t CreateDataBase(const char *dbname) final;
42  Int_t DropDataBase(const char *dbname) final;
43  Int_t Reload() final;
44  Int_t Shutdown() final;
45  const char *ServerInfo() final;
46 
47  ClassDefOverride(TPgSQLServer,0) // Connection to PgSQL server
48 };
49 
50 #endif
Option_t
const char Option_t
Definition: RtypesCore.h:66
TPgSQLServer::Close
void Close(Option_t *opt="") final
Close connection to PgSQL DB server.
Definition: TPgSQLServer.cxx:109
TSQLServer.h
TPgSQLServer::HasStatement
Bool_t HasStatement() const final
PG_VERSION_NUM conveniently only started being #defined at 8.2.3 which is the first version of libpq ...
Definition: TPgSQLServer.cxx:343
TPgSQLServer
Definition: TPgSQLServer.h:22
TSQLTableInfo
Definition: TSQLTableInfo.h:20
TPgSQLServer::fPgSQL
PGconn * fPgSQL
Definition: TPgSQLServer.h:25
TString
Basic string class.
Definition: TString.h:136
TPgSQLServer::~TPgSQLServer
~TPgSQLServer()
Close connection to PgSQL DB server.
Definition: TPgSQLServer.cxx:100
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
bool
TSQLResult
Definition: TSQLResult.h:32
TPgSQLServer::GetTableInfo
TSQLTableInfo * GetTableInfo(const char *tablename) final
Produce TSQLTableInfo.
Definition: TPgSQLServer.cxx:394
TPgSQLServer::Statement
TSQLStatement * Statement(const char *sql, Int_t=100) final
Produce TPgSQLStatement.
Definition: TPgSQLServer.cxx:358
TPgSQLServer::SelectDataBase
Int_t SelectDataBase(const char *dbname) final
Select a database. Returns 0 if successful, non-zero otherwise.
Definition: TPgSQLServer.cxx:146
TPgSQLServer::DropDataBase
Int_t DropDataBase(const char *dbname) final
Drop (i.e.
Definition: TPgSQLServer.cxx:282
TPgSQLServer::TPgSQLServer
TPgSQLServer(const char *db, const char *uid, const char *pw)
Open a connection to a PgSQL DB server.
Definition: TPgSQLServer.cxx:43
TPgSQLServer::GetColumns
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=nullptr) final
List all columns in specified table in the specified database.
Definition: TPgSQLServer.cxx:233
TPgSQLServer::Reload
Int_t Reload() final
Reload permission tables.
Definition: TPgSQLServer.cxx:299
TPgSQLServer::GetDataBases
TSQLResult * GetDataBases(const char *wild=nullptr) final
List all available databases.
Definition: TPgSQLServer.cxx:188
TPgSQLServer::CreateDataBase
Int_t CreateDataBase(const char *dbname) final
Create a database. Returns 0 if successful, non-zero otherwise.
Definition: TPgSQLServer.cxx:265
TPgSQLServer::fSrvInfo
TString fSrvInfo
Definition: TPgSQLServer.h:26
TSQLStatement
Definition: TSQLStatement.h:21
TPgSQLServer::ServerInfo
const char * ServerInfo() final
Return server info.
Definition: TPgSQLServer.cxx:328
TPgSQLServer::GetTables
TSQLResult * GetTables(const char *dbname, const char *wild=nullptr) final
List all tables in the specified database.
Definition: TPgSQLServer.cxx:208
TPgSQLServer::Query
TSQLResult * Query(const char *sql) final
Execute SQL command.
Definition: TPgSQLServer.cxx:123
TPgSQLServer::Shutdown
Int_t Shutdown() final
Shutdown the database server.
Definition: TPgSQLServer.cxx:314
TSQLServer
Definition: TSQLServer.h:41
TPgSQLServer::fOidTypNameMap
std::map< Int_t, std::string > fOidTypNameMap
Definition: TPgSQLServer.h:27
int