Version: 1.0.0
postgresql_database.h
Go to the documentation of this file.
1 #ifndef _WX_DATABASE_POSTGRESQL_DATABASE_H_
2 #define _WX_DATABASE_POSTGRESQL_DATABASE_H_
3 
4 #include "wx/database/wxprec.h"
5 
6 #ifndef DONT_USE_DYNAMIC_DATABASE_LINKING
8 #endif
9 
10 
12 {
13 public:
14  // Information that can be specified for a PostgreSQL database
15  // host or hostaddr
16  // port
17  // dbname
18  // user
19  // password
20  // ctor
22  wxPostgresDatabase(const wxString& strDatabase);
23  wxPostgresDatabase(const wxString& strServer, const wxString& strDatabase);
24  wxPostgresDatabase(const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
25  wxPostgresDatabase(const wxString& strServer, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
26  wxPostgresDatabase(const wxString& strServer, int nPort, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
27  wxPostgresDatabase(void* pDatabase) { m_pDatabase = pDatabase; }
28 
29  // dtor
30  virtual ~wxPostgresDatabase();
31 
32  // open database
33  virtual bool Open();
34  virtual bool Open(const wxString& strDatabase);
35  virtual bool Open(const wxString& strServer, const wxString& strDatabase);
36  virtual bool Open(const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
37  virtual bool Open(const wxString& strServer, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
38  virtual bool Open(const wxString& strServer, int nPort, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
39 
40  // close database
41  virtual bool Close();
42 
43  // Is the connection to the database open?
44  virtual bool IsOpen();
45 
46  // transaction support
47  virtual void BeginTransaction();
48  virtual void Commit();
49  virtual void RollBack();
50 
51  // query database
52  virtual int RunQuery(const wxString& strQuery, bool bParseQuery);
53  virtual wxDatabaseResultSet* RunQueryWithResults(const wxString& strQuery);
54 
55  // wxPreparedStatement support
56  virtual wxPreparedStatement* PrepareStatement(const wxString& strQuery);
57 
58  // Database schema API contributed by M. Szeftel (author of wxActiveRecordGenerator)
59  virtual bool TableExists(const wxString& table);
60  virtual bool ViewExists(const wxString& view);
61  virtual wxArrayString GetTables();
62  virtual wxArrayString GetViews();
63  virtual wxArrayString GetColumns(const wxString& table);
64  virtual wxArrayString GetPKColumns(const wxString& table);
65 
66  void SetPort(int nPort);
67 
68  static int TranslateErrorCode(int nCode);
69  static bool IsAvailable();
70 
71 private:
72 #ifndef DONT_USE_DYNAMIC_DATABASE_LINKING
74 #endif
75  wxString m_strServer;
76  wxString m_strDatabase;
77  wxString m_strUser;
78  wxString m_strPassword;
79  wxString m_strPort;
80 
81  void* m_pDatabase;
82 };
83 
84 #endif//_WX_DATABASE_POSTGRESQL_DATABASE_H_
85 
virtual wxArrayString GetPKColumns(const wxString &table)=0
get Primary keys column names
virtual wxArrayString GetViews()=0
Retrieve all view names.
wxPostgresDatabase(void *pDatabase)
virtual wxPreparedStatement * PrepareStatement(const wxString &strQuery)=0
Prepare a SQL statement which can be reused with different parameters.
virtual void RollBack()=0
Rollback the current transaction.
virtual bool IsOpen()=0
Is the connection to the database open?
virtual int RunQuery(const wxString &strQuery)
Run an insert, update, or delete query on the database.
Definition: database.cpp:19
virtual void BeginTransaction()=0
Begin a transaction.
virtual bool Open(const wxString &strDatabase)=0
virtual bool ViewExists(const wxString &view)=0
Check for the existence of a view by name.
wxDynamicPostgresInterface * m_pInterface
virtual void Commit()=0
Commit the current transaction.
virtual wxArrayString GetColumns(const wxString &table)=0
Retrieve all column names for a table.
virtual bool Close()=0
close database
virtual bool TableExists(const wxString &table)=0
Check for the existence of a table by name.
#define WXDLLIMPEXP_DATABASE
virtual wxArrayString GetTables()=0
Retrieve all table names.
virtual wxDatabaseResultSet * RunQueryWithResults(const wxString &strQuery)=0
Run a select query on the database.