Neuroshok DataBase

Related tags

Database ndb
Overview

Neuroshok Database Interface

gcc8.1 / clang8.0 / msvc19.16
Master
Dev

ndb is a generic interface to connect to any database. Queries are written in pure C++ and can be executed on different database engines just by changing one parameter. Database model is defined and accessible at compile time.

Features

  • Header only interface
  • Full C++ and generic queries
  • Support any type of databases
  • Easy to add new engines
  • Compile-time generation for SQL expressions
  • Customizable types conversion
  • Field access by C++ structure
  • Database generation with macros

Current support

  • Expressions based on SQL and BSON
  • Sqlite, PostgreSQL and MongoDB.

How to use

Choose the branch to clone (master or dev)

[email protected]:/home/ads$ git clone -b [branch] https://github.com/ads00/ndb.git

Build (optional)

Create build directory

[email protected]:/home/ads/ndb$ mkdir build && cd build

Bundled engines

Choose engines with option -DNDB_ENGINE_[name]=ON (ex: -DNDB_ENGINE_SQLITE=ON)

Options

-DNDB_BUILD_TEST=ON -DNDB_BUILD_EXAMPLE=ON

[email protected]:/home/ads/ndb/build$ cmake -DNDB_ENGINE_SQLITE=ON [options] -DCMAKE_BUILD_TYPE=Release ..
[email protected]:/home/ads/ndb/build$ make
(optional) [email protected]:/home/ads/ndb/build$ make test

Integration

CMake

add_subdirectory(${PATH_TO_NDB}/ndb ${THIRD_PARTY_ROOT}/ndb/cmake-build)
target_link_libraries(my_target lib_ndb)

Manual

Add paths to ndb headers and your custom engine builds

Overview

Database

ndb_table(movie,
          ndb_field_id,
          ndb_field(name, std::string, ndb::size<255>)
)
ndb_table(music,
          ndb_field_id,
          ndb_field(image, std::string, ndb::size<255>)
)
ndb_model(collection, movie, music)

ndb_project(my_project,
            ndb_database(libray, collection, ndb::sqlite),
            ndb_database(mongo_library, collection, ndb::mongo)
)

Queries

ndb::query<dbs::zeta>() << ( movie.id, movie.image ); // get
ndb::query<dbs::zeta>() << ( movie.id == a && movie.name == b ); // get by condition
ndb::query<dbs::zeta>() >> (( movie.name = "updated") << ( movie.id == 3 )); // update by condition
ndb::query<dbs::zeta>() + ( movie.id = 3, movie.name = "test" ); // add
ndb::query<dbs::zeta>() - ( movie.id == 3 ); // del

Example

An example with a libray database using a collection model and a movie table

#include "my_database.h"

// aliases
namespace dbs
{
    using libray = ndb::databases::my_project::libray_;
    using mongo_library = ndb::databases::my_project::mongo_library_;
}

int main()
{
    // alias
    const auto& movie = ndb::models::collection.movie;
    
    // initialize sqlite and mongo
    ndb::initializer<ndb::sqlite, ndb::mongo> init;
    
    // connect to database library (sqlite is used)
    ndb::connect<dbs::library>();
    
    // connect to database mongo_library (mongo is used)
    ndb::connect<dbs::mongo_library>();  

    // add a movie with specified movie.name and movie.duration (table is deduced compile time)
    ndb::query<dbs::library>() + (movie.name = "Interstellar", movie.duration = 2.49_h) );
    
    // get all fields from movie where duration is less than 2H30
    for (auto& line : ndb::query<dbs::library>() << (movie.duration <= 3.30_h))
    {
        std::cout << "movie.name : " << line[movie.name] << std::endl;
        std::cout << "movie.duration : " << line[movie.duration] << std::endl; 
    }

    return 0;
}

Documentation

Example

Contribution

ads00

Jonathan Poelen (@jonathanpoelen)

You might also like...
OceanBase is an enterprise distributed relational database with high availability, high performance, horizontal scalability, and compatibility with SQL standards.

What is OceanBase database OceanBase Database is a native distributed relational database. It is developed entirely by Alibaba and Ant Group. OceanBas

SOCI - The C++ Database Access Library

Originally, SOCI was developed by Maciej Sobczak at CERN as abstraction layer for Oracle, a Simple Oracle Call Interface. Later, several database backends have been developed for SOCI, thus the long name has lost its practicality. Currently, if you like, SOCI may stand for Simple Open (Database) Call Interface or something similar.

StarRocks is a next-gen sub-second MPP database for full analysis senarios, including multi-dimensional analytics, real-time analytics and ad-hoc query, formerly known as DorisDB.

StarRocks is a next-gen sub-second MPP database for full analysis senarios, including multi-dimensional analytics, real-time analytics and ad-hoc query, formerly known as DorisDB.

BaikalDB, A Distributed HTAP Database.

BaikalDB supports sequential and randomised realtime read/write of structural data in petabytes-scale. BaikalDB is compatible with MySQL protocol and it supports MySQL style SQL dialect, by which users can migrate their data storage from MySQL to BaikalDB seamlessly.

Velox is a new C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.
Velox is a new C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.

Velox is a C++ database acceleration library which provides reusable, extensible, and high-performance data processing components

Test any type of cloud database on Android apps. No need of a dedicated backend.

DB Kong - Database connections simplified DB Kong is an Android library that allows you to connect, interact and test any type of cloud database on An

The fastest database-library on Android OS.

Android SQLite3 NDK 封装 Demo下载 (操作:按钮新增 按钮查询 点按编辑 长按删除) 写在前面 sqlite3 开源、集成简单(现在的版本只有2个文件 sqlite3.h sqlite3.c) 这个库抽离自 Telegram 的开源代码、作者:DrKLO 我个人感觉 Tele

LogMessage is one of the output format of database incremental data

LogMessage LogMessage是一种数据库增量数据的输出格式,oceanbase的增量采集模块liboblog正是使用的这种消息格式来输出增量数据,LogMessage支持oceanbase中不同数据类型的增量数据的写入,具有序列化和反序列化的能力。 如何编译 LogMessage的编译

GalaxyEngine is a MySQL branch originated from Alibaba Group, especially supports large-scale distributed database system.

GalaxyEngine is a MySQL branch originated from Alibaba Group, especially supports large-scale distributed database system.

Comments
  • [BUG] Issue with oquery

    [BUG] Issue with oquery

    I'm trying to use oquery, but I have an exception.

    Here is my code :

    for (auto& data : ndb::oquery<dbs::password>() << autofill_encrypted) {
    	if (QString::fromStdString(data.server) == INTERNAL_SERVER_ID)
    		continue;
    
    	if (decryptPasswordEntry(PasswordEntry(data), &aesDecryptor))
    		list.append(PasswordEntry(data));
    }
    

    The exception thrown is : Field does not exist in the result, check the select clause\nfrom ndb::line<class ndb::sqlite>::operator [].

    My table is empty and I simply whould excepte that if it's empty, the for is never reached instead of throwing an exception. :wink:

    opened by Feldrise 1
  • Add some informations to the README

    Add some informations to the README

    I added some informations to the README in this section :

    ## Integration
    ### CMake
    

    To make a summary, I added a missing CMake property and warning about the options position and a possible load error.

    opened by Feldrise 1
  • Add possibility to have default value

    Add possibility to have default value

    NULL values throw exceptions currently, so at least provide the possibility to have default value in order to not have to put a value in all field in an INSERT query.

    opened by Feldrise 0
Owner
null
A mini database for learning database

A mini database for learning database

Chuckie Tan 4 Nov 14, 2022
ESE is an embedded / ISAM-based database engine, that provides rudimentary table and indexed access.

Extensible-Storage-Engine A Non-SQL Database Engine The Extensible Storage Engine (ESE) is one of those rare codebases having proven to have a more th

Microsoft 789 Nov 20, 2022
Nebula Graph is a distributed, fast open-source graph database featuring horizontal scalability and high availability

Nebula Graph is an open-source graph database capable of hosting super large scale graphs with dozens of billions of vertices (nodes) and trillions of edges, with milliseconds of latency.

vesoft inc. 832 Nov 10, 2022
DuckDB is an in-process SQL OLAP Database Management System

DuckDB is an in-process SQL OLAP Database Management System

DuckDB 7.4k Nov 23, 2022
YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features

YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features. It is best to fit for cloud-native OLTP (i.e. real-time, business-critical) applications that need absolute data correctness and require at least one of the following: scalability, high tolerance to failures, or globally-distributed deployments.

yugabyte 7.3k Nov 24, 2022
TimescaleDB is an open-source database designed to make SQL scalable for time-series data.

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.

Timescale 14.1k Nov 22, 2022
Beryl-cli is a client for the BerylDB database server

Beryl-cli is a client for the BerylDB database server. It offers multiple commands and is designed to be fast and user-friendly.

BerylDB 11 Oct 9, 2022
PolarDB for PostgreSQL (PolarDB for short) is an open source database system based on PostgreSQL.

PolarDB for PostgreSQL (PolarDB for short) is an open source database system based on PostgreSQL. It extends PostgreSQL to become a share-nothing distributed database, which supports global data consistency and ACID across database nodes, distributed SQL processing, and data redundancy and high availability through Paxos based replication. PolarDB is designed to add values and new features to PostgreSQL in dimensions of high performance, scalability, high availability, and elasticity. At the same time, PolarDB remains SQL compatibility to single-node PostgreSQL with best effort.

Alibaba 2.5k Nov 17, 2022
A MariaDB-based command line tool to connect to OceanBase Database.

什么是 OceanBase Client OceanBase Client(简称 OBClient) 是一个基于 MariaDB 开发的客户端工具。您可以使用 OBClient 访问 OceanBase 数据库的集群。OBClient 采用 GPL 协议。 OBClient 依赖 libobclie

OceanBase 51 Nov 9, 2022
A proxy server for OceanBase Database.

OceanBase Database Proxy TODO: some badges here OceanBase Database Proxy (ODP for short) is a dedicated proxy server for OceanBase Database. OceanBase

OceanBase 78 Nov 9, 2022