| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2014 Eran Ifrah |
| 5 |
// file name : PostgreSqlDbAdapter.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
|
| 26 |
#ifndef POSTGRESQLDBADAPTER_H |
| 27 |
#define POSTGRESQLDBADAPTER_H |
| 28 |
|
| 29 |
#ifdef DBL_USE_POSTGRES |
| 30 |
#include <wx/dblayer/include/PostgresDatabaseLayer.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
#include <wx/dblayer/include/DatabaseLayer.h> |
| 34 |
#include <wx/dynarray.h> |
| 35 |
#include "IDbAdapter.h" // Base class: IDbAdapter |
| 36 |
#include "IDbType.h" |
| 37 |
#include "PostgreSqlType.h" |
| 38 |
|
| 39 |
|
| 40 |
class PostgreSqlDbAdapter : public IDbAdapter { |
| 41 |
|
| 42 |
public: |
| 43 |
PostgreSqlDbAdapter(); |
| 44 |
PostgreSqlDbAdapter(const wxString& serverName,const int port, const wxString& defaultDb, const wxString& userName, const wxString& password); |
| 45 |
~PostgreSqlDbAdapter(); |
| 46 |
|
| 47 |
virtual bool GetColumns(Table* pTab); |
| 48 |
virtual void GetDatabases(DbConnection* dbCon); |
| 49 |
virtual void GetTables(Database* db, bool includeViews); |
| 50 |
virtual void GetViews(Database* db); |
| 51 |
|
| 52 |
virtual IDbAdapter* Clone(); |
| 53 |
virtual bool CanConnect(); |
| 54 |
virtual bool IsConnected(); |
| 55 |
virtual void CloseConnection(); |
| 56 |
virtual DatabaseLayerPtr GetDatabaseLayer(const wxString& dbName); |
| 57 |
|
| 58 |
virtual wxString GetUseDb(const wxString& dbName); |
| 59 |
virtual wxString GetDefaultSelect(const wxString& dbName, const wxString& tableName); |
| 60 |
virtual wxString GetDefaultSelect(const wxString& cols, const wxString& dbName, const wxString& tableName); |
| 61 |
virtual wxString GetCreateTableSql(Table* tab, bool dropTable); |
| 62 |
virtual wxString GetCreateViewSql(View* view, bool dropView); |
| 63 |
virtual wxString GetAlterTableConstraintSql(Table* tab); |
| 64 |
virtual wxString GetCreateDatabaseSql(const wxString& dbName); |
| 65 |
virtual wxString GetDropTableSql(Table* pTab); |
| 66 |
virtual wxString GetDropViewSql(View* pView); |
| 67 |
virtual wxString GetDropDatabaseSql(Database* pDb); |
| 68 |
|
| 69 |
virtual IDbType* GetDbTypeByName(const wxString& typeName); |
| 70 |
virtual wxArrayString* GetDbTypes(); |
| 71 |
|
| 72 |
|
| 73 |
virtual IDbType* GetDbTypeByUniversalName(IDbType::UNIVERSAL_TYPE type); |
| 74 |
virtual void ConvertTable(Table* pTab); |
| 75 |
virtual IDbType* ConvertType(IDbType* pType); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
protected: |
| 80 |
//void SetDatabase(const wxString& db) { m_defaultDb = db; } |
| 81 |
|
| 82 |
IDbType* parseTypeString(const wxString& typeString); |
| 83 |
|
| 84 |
wxString m_serverName; |
| 85 |
int m_port; |
| 86 |
wxString m_userName; |
| 87 |
wxString m_password; |
| 88 |
wxString m_defaultDb; |
| 89 |
|
| 90 |
DatabaseLayer* m_pDbLayer; |
| 91 |
}; |
| 92 |
|
| 93 |
#endif // POSTGRESQLDBADAPTER_H |