mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
ea31171873
* when none is given * if the given save-code already exist * if the database connection fails therefore it can't be checked if the save-code already exists Using the short word list from eff: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#ifndef ENGINE_SERVER_SQL_SERVER_H
|
|
#define ENGINE_SERVER_SQL_SERVER_H
|
|
|
|
#include <base/tl/threading.h>
|
|
|
|
#include <mysql_connection.h>
|
|
|
|
#include <cppconn/driver.h>
|
|
#include <cppconn/exception.h>
|
|
#include <cppconn/statement.h>
|
|
|
|
class CSqlServer
|
|
{
|
|
public:
|
|
CSqlServer(const char *pDatabase, const char *pPrefix, const char *pUser, const char *pPass, const char *pIp, int Port, lock *pGlobalLock, bool ReadOnly = true, bool SetUpDb = false);
|
|
~CSqlServer();
|
|
|
|
bool Connect();
|
|
void Disconnect();
|
|
bool CreateTables();
|
|
|
|
void executeSql(const char *pCommand);
|
|
void executeSqlQuery(const char *pQuery);
|
|
|
|
sql::ResultSet* GetResults() { return m_pResults; }
|
|
|
|
const char* GetDatabase() { return m_aDatabase; }
|
|
const char* GetPrefix() { return m_aPrefix; }
|
|
const char* GetUser() { return m_aUser; }
|
|
const char* GetPass() { return m_aPass; }
|
|
const char* GetIP() { return m_aIp; }
|
|
int GetPort() { return m_Port; }
|
|
sql::Connection *Connection() const { return m_pConnection; }
|
|
|
|
static int ms_NumReadServer;
|
|
static int ms_NumWriteServer;
|
|
|
|
private:
|
|
sql::Driver *m_pDriver;
|
|
sql::Connection *m_pConnection;
|
|
sql::Statement *m_pStatement;
|
|
sql::ResultSet *m_pResults;
|
|
|
|
// copy of config vars
|
|
char m_aDatabase[64];
|
|
char m_aPrefix[64];
|
|
char m_aUser[64];
|
|
char m_aPass[64];
|
|
char m_aIp[64];
|
|
int m_Port;
|
|
|
|
bool m_SetUpDB;
|
|
|
|
lock m_SqlLock;
|
|
lock *m_pGlobalLock;
|
|
};
|
|
|
|
#endif
|