Former-commit-id: 1c21d81875ec000c6f26ef8f2c367df8992fde59
This commit is contained in:
xj.lin 2019-04-18 11:21:49 +08:00
parent a7657e1e3d
commit 465bd19948
2 changed files with 12 additions and 10 deletions

View File

@ -6,22 +6,18 @@
#include "db_connection.h"
#include <string>
#include <iostream>
#include <thread>
namespace zilliz {
namespace vecwise {
namespace engine {
using std::cout;
using std::endl;
using std::string;
using namespace sqlite_orm;
string storage_file_name = "default.sqlite"
string storage_file_name = "default.sqlite";
DbPtr connect() {
DbPtr temp = std::make_shared<SqliteDB>(initStorage(storage_file_name));
SqliteDBPtr connect() {
SqliteDBPtr temp = std::make_shared<SqliteDB>(initStorage(storage_file_name));
temp->sync_schema();
temp->open_forever(); // thread safe option
temp->pragma.journal_mode(journal_mode::WAL); // WAL => write ahead log

View File

@ -6,6 +6,11 @@
#pragma once
#include <string>
#include <memory>
#include <sqlite_orm/sqlite_orm.h>
namespace zilliz {
namespace vecwise {
@ -36,8 +41,9 @@ struct GroupFileSchema {
}; // GroupFileSchema
inline auto initStorage(const std::string &path) {
using namespace sqlite_orm;
return make_storage(path,
// Add table below
// Add table below
make_table("Groups",
make_column("id", &GroupSchema::id, primary_key()),
make_column("group_id", &GroupSchema::group_id, unique()),
@ -46,7 +52,7 @@ inline auto initStorage(const std::string &path) {
}
using SqliteDB = decltype(initStorage(""));
using SqliteDBPtr= std::shared_ptr<Db>;
using SqliteDBPtr= std::shared_ptr<SqliteDB>;
class Connection {
protected: