mirror of
https://github.com/getml/sqlgen.git
synced 2026-01-02 07:30:17 -06:00
Added write functions
This commit is contained in:
30
tests/sqlite/test_write.cpp
Normal file
30
tests/sqlite/test_write.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <sqlgen.hpp>
|
||||
#include <sqlgen/sqlite.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace test_write {
|
||||
|
||||
struct Person {
|
||||
sqlgen::PrimaryKey<uint32_t> id;
|
||||
std::string first_name;
|
||||
std::string last_name;
|
||||
int age;
|
||||
};
|
||||
|
||||
TEST(sqlite, test_write) {
|
||||
const auto conn = sqlgen::sqlite::connect().value();
|
||||
|
||||
const auto people = std::vector<Person>(
|
||||
{Person{
|
||||
.id = 0, .first_name = "Homer", .last_name = "Simpson", .age = 45},
|
||||
Person{.id = 1, .first_name = "Bart", .last_name = "Simpson", .age = 10},
|
||||
Person{.id = 2, .first_name = "Lisa", .last_name = "Simpson", .age = 8},
|
||||
Person{
|
||||
.id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}});
|
||||
|
||||
sqlgen::write(conn, people.begin(), people.end()).value();
|
||||
}
|
||||
|
||||
} // namespace test_write
|
||||
Reference in New Issue
Block a user