Import SQLite3 wrapper implementation from old repo

This commit is contained in:
TennesseeTrash 2025-06-09 01:41:27 +02:00
parent f9c6e9e7cb
commit 405b68b824
5 changed files with 826 additions and 0 deletions

View file

@ -1,3 +1,4 @@
include(${PROJECT_SOURCE_DIR}/CMake/Catch2.cmake)
add_subdirectory(Base64)
add_subdirectory(SQLite)

View file

@ -0,0 +1,20 @@
include(${PROJECT_SOURCE_DIR}/CMake/sqlite3.cmake)
add_executable(TestSQLite)
target_compile_features(TestSQLite
PRIVATE
cxx_std_20
)
target_link_libraries(TestSQLite
PRIVATE
Garbage
sqlite3
Catch2::Catch2WithMain
)
target_sources(TestSQLite
PRIVATE
Main.cpp
)

35
Tests/SQLite/Main.cpp Normal file
View file

@ -0,0 +1,35 @@
#include <Garbage/SQLite.hpp>
using namespace Garbage::SQLite;
struct User
{
std::int64_t Id;
std::string Username;
std::string Email;
std::string PasswordHash;
};
Database db(
"UserDb",
Table(
"Users",
Column(&User::Id, "Id", ColumnFlags::PrimaryKey),
Column(&User::Username, "Username", ColumnFlags::Unique),
Column(&User::Email, "Email", ColumnFlags::Unique),
Column(&User::PasswordHash, "PasswordHash")
)
);
int main() {
User u {
.Id = 25,
.Username = "noob",
.Email = "noob@noob.io",
.PasswordHash = "ASDASDASDASDASDA",
};
Connection c(db, "Test.db");
c.Create();
c.Insert(u);
}