UniSet  2.2.1
PostgreSQLInterface.h
00001 //----------------------------------------------------------------------------
00002 #ifndef PostgreSQLInterface_H_
00003 #define PostgreSQLInterface_H_
00004 // ---------------------------------------------------------------------------
00005 #include <string>
00006 #include <list>
00007 #include <vector>
00008 #include <iostream>
00009 #include <pqxx/pqxx>
00010 #include <PassiveTimer.h>
00011 #include <DBInterface.h>
00012 // ----------------------------------------------------------------------------
00013 class PostgreSQLInterface:
00014     public DBNetInterface
00015 {
00016     public:
00017 
00018         PostgreSQLInterface();
00019         ~PostgreSQLInterface();
00020 
00021         virtual bool nconnect( const std::string& host, const std::string& user, const std::string& pswd, const std::string& dbname ) override;
00022         virtual bool close() override;
00023         virtual bool isConnection() override;
00024         virtual bool ping() override; // проверка доступности БД
00025 
00026         virtual DBResult query( const std::string& q ) override;
00027         virtual const std::string lastQuery() override;
00028 
00029         virtual bool insert( const std::string& q ) override;
00030         bool insertAndSaveRowid( const std::string& q );
00031         virtual double insert_id() override;
00032         void save_inserted_id( const pqxx::result& res );
00033 
00034         virtual const std::string error() override;
00035 
00036     protected:
00037 
00038     private:
00039 
00040         void makeResult(DBResult& dbres, const pqxx::result& res );
00041         std::shared_ptr<pqxx::connection> db;
00042         std::string lastQ;
00043         std::string lastE;
00044         double last_inserted_id;
00045 };
00046 // ----------------------------------------------------------------------------
00047 #endif
00048 // ----------------------------------------------------------------------------------