Import SQLite3 wrapper implementation from old repo
This commit is contained in:
parent
f9c6e9e7cb
commit
405b68b824
5 changed files with 826 additions and 0 deletions
20
Tests/SQLite/CMakeLists.txt
Normal file
20
Tests/SQLite/CMakeLists.txt
Normal 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
35
Tests/SQLite/Main.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue