Absolute basics of database creation

This commit is contained in:
Shaquille Soekhlal 2019-05-21 21:02:40 -03:00
parent 48eec85893
commit 92612eb4ef

View File

@ -1,14 +1,41 @@
#include <iostream> #include <iostream>
#include <string>
#include "headers/3rd-party/sqlite_orm.h" #include "headers/3rd-party/sqlite_orm.h"
class item{ using namespace sqlite_orm;
public:
private: static inline std::string getPath(){
std::string filePath(__FILE__);
return filePath.substr( 0, filePath.length() - std::string("main.cpp").length());
}
static const std::string sqlitedb = getPath() + "/sqlite.db3";
struct employee{
int id;
std::string first_name;
std::string last_name;
double salary;
}; };
auto employees = make_storage("sqlite.db3",
make_table("Employees",
make_column("id", &employee::id, autoincrement(), primary_key()),
make_column("first_name", &employee::first_name),
make_column("last_name", &employee::last_name),
make_column("salary", &employee::salary)
)
);
// class item{
// public:
// private:
// };
int main(){ int main(){
std::cout << "Hello"; employees.sync_schema();
//std::cout << sqlitedb;
system("PAUSE");
return 0; return 0;
} }