init session db class

This commit is contained in:
yggverse 2024-08-11 14:28:14 +03:00
parent 814b25a946
commit 7a04fb8920
6 changed files with 65 additions and 1 deletions

View File

@ -11,7 +11,8 @@ SRCS = src/main.cpp\
src/app/browser/header/menu.cpp\
src/app/browser/header/tab.cpp\
src/app/browser/page.cpp\
src/lib/database.cpp
src/lib/database.cpp\
src/lib/database/session.cpp
OBJS = $(SRCS:.cpp=.o)

View File

@ -8,6 +8,9 @@ src/app/browser/header/tab.cpp
src/app/browser/header/tab.hpp
src/app/browser/page.cpp
src/app/browser/page.hpp
src/lib/database.cpp
src/lib/database.hpp
src/lib/database/session.cpp
src/lib/database/session.hpp
src/main.cpp
src/main.hpp

View File

@ -1,4 +1,5 @@
#include "database.hpp"
#include "database/session.hpp"
using namespace lib;
@ -9,4 +10,8 @@ Database::Database(
filename,
&connection
);
session = new database::Session(
connection
);
}

View File

@ -5,6 +5,11 @@
namespace lib
{
namespace database
{
class Session;
}
class Database
{
private:
@ -17,6 +22,8 @@ namespace lib
public:
database::Session * session;
Database(
const char * filename
);

View File

@ -0,0 +1,22 @@
#include "session.hpp"
using namespace lib::database;
Session::Session(
sqlite3 * connection
) {
status = sqlite3_exec(
connection,
R"(
CREATE TABLE IF NOT EXISTS `session`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`time` INTEGER NOT NULL,
`request` VARCHAR(1024)
)
)",
nullptr,
nullptr,
&error
);
}

View File

@ -0,0 +1,26 @@
#ifndef LIB_DATABASE_SESSION_H
#define LIB_DATABASE_SESSION_H
#include <sqlite3.h>
namespace lib::database
{
class Session
{
private:
int status;
char * error;
sqlite3 * connection;
public:
Session(
sqlite3 * connection
);
};
}
#endif // LIB_DATABASE_SESSION_H