Giter Site home page Giter Site logo

codacy-badger / sqlpp11-connector-postgresql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matthijs/sqlpp11-connector-postgresql

0.0 0.0 0.0 496 KB

PostgreSQL connector for sqlpp11 library

License: BSD 2-Clause "Simplified" License

CMake 5.62% C++ 90.63% C 0.88% Python 2.87%

sqlpp11-connector-postgresql's Introduction

sqlpp11-connector-postgresql

PostgreSQL connector for sqlpp11 library

License:

sqlpp11 is distributed under the BSD 2-Clause License.

Status:

Branch / Compiler gcc 4.8 MSVC 2015/2017 Code coverage
master Build Status Build status Coverage Status
develop Build Status Build status Coverage Status

Examples

An example on how to use this library

auto config = std::make_shared<sqlpp::postgresql::connection_config>();
config->host = "127.0.0.1";
config->user = "someuser";
config->password = "some-random-password";
config->dbname = "somedb";

sqlpp::postgresql::connection db(config);

TabFoo foo;
for(const auto& row: db(select(foo.name, foo.hasFun).from(foo).where(foo.id > 17 and foo.name.like("%bar%"))) {
  std::cerr << row.name << std::endl;
}

The library supports also 'ON CONFLICT'. This way INSERT or UPDATE can be implemented. To use it one can use it with the following code:

auto config = std::make_shared<sqlpp::postgresql::connection_config>();
config->host = "127.0.0.1";
config->user = "someuser";
config->password = "some-random-password";
config->dbname = "somedb";

sqlpp::postgresql::connection db(config);

TabFoo foo;
db(insert_into(foo).default_values().on_conflict().do_nothing());
db(insert_into(foo).default_values().on_conflict(foo.id).do_nothing());
db(insert_into(foo).default_values().on_conflict(foo.id).do_update(foo.name = "some data", foo.hasFun = true);
db(insert_into(foo).default_values().on_conflict(foo.id).do_update(foo.name = "some data", foo.hasFun = true).where(foo.hasFun == false));

The only limitation in on_conflict() is the conflict_target. Only a column is supported in the conflict_target. If there is need for a more sophisticated conflict_target please create an issue.

Connection configuration

You can use all possible authentication options that are available in PostgreSQL. See here for more information about the options.

sqlpp11-connector-postgresql's People

Contributors

adiog avatar cszawisza avatar dhgelling avatar dirkvdb avatar gagbo avatar ianda avatar konubinix avatar markwright avatar matthijs avatar mickeyzoox avatar rbock avatar sjoubert avatar valsydalv avatar volka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.