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
22class TPgSQLServer : public TSQLServer {
23
24private:
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()
28public:
29 TPgSQLServer(const char *db, const char *uid, const char *pw);
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
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
TSQLResult * GetTables(const char *dbname, const char *wild=nullptr) final
List all tables in the specified database.
Int_t CreateDataBase(const char *dbname) final
Create a database. Returns 0 if successful, non-zero otherwise.
TSQLResult * Query(const char *sql) final
Execute SQL command.
const char * ServerInfo() final
Return server info.
Int_t SelectDataBase(const char *dbname) final
Select a database. Returns 0 if successful, non-zero otherwise.
Bool_t HasStatement() const final
PG_VERSION_NUM conveniently only started being #defined at 8.2.3 which is the first version of libpq ...
TSQLTableInfo * GetTableInfo(const char *tablename) final
Produce TSQLTableInfo.
std::map< Int_t, std::string > fOidTypNameMap
Definition: TPgSQLServer.h:27
Int_t Reload() final
Reload permission tables.
Int_t Shutdown() final
Shutdown the database server.
Int_t DropDataBase(const char *dbname) final
Drop (i.e.
TSQLResult * GetDataBases(const char *wild=nullptr) final
List all available databases.
PGconn * fPgSQL
Definition: TPgSQLServer.h:25
void Close(Option_t *opt="") final
Close connection to PgSQL DB server.
TPgSQLServer(const char *db, const char *uid, const char *pw)
Open a connection to a PgSQL DB server.
TString fSrvInfo
Definition: TPgSQLServer.h:26
TSQLStatement * Statement(const char *sql, Int_t=100) final
Produce TPgSQLStatement.
~TPgSQLServer()
Close connection to PgSQL DB server.
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=nullptr) final
List all columns in specified table in the specified database.
Basic string class.
Definition: TString.h:136