seperete create_tables

This commit is contained in:
Nikola Petrov 2025-01-31 00:18:58 +01:00
parent 4c38bfe9a6
commit 3ea3ef7c11
3 changed files with 58 additions and 51 deletions

View File

@ -117,6 +117,7 @@ void call(int sock, sockaddr_in newSocketInfo)
int main()
{
sql::init();
sql::create_tables();
std::thread t(checker);
// Bind the server to a port.
int err = TcpSocket::listent("0.0.0.0", serverPort, call);

View File

@ -32,6 +32,7 @@ struct sqlite3_stmt;
namespace sql
{
void create_tables();
void init();
void shutdown();
int open(const char *filename, sqlite3 **ppDb);

View File

@ -5,9 +5,11 @@
#include <sqlite3.h>
void sql::init()
namespace sql
{
sqlite3_initialize();
void create_tables()
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
@ -49,15 +51,18 @@ void sql::init()
}
sqlite3_close(db);
}
}
void sql::shutdown()
{
void init()
{
sqlite3_initialize();
}
void shutdown()
{
sqlite3_shutdown();
}
}
namespace sql
{
int open(const char *filename, sqlite3 **ppDb)
{
return sqlite3_open(filename, ppDb);