No description, website, or topics provided.
Switch branches/tags
Clone or download
amantia Merge pull request #8 from KDAB/sql_delete
Sql delete statement implementation
Latest commit d7f00ed Jun 2, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
procedures/pre-create Initial import of the TMP based SQL access take from one of our proje… Jun 24, 2013
tests Implement del expression for SQL DELETE Apr 10, 2017
.gitignore Initial import of the TMP based SQL access take from one of our proje… Jun 24, 2013
CMakeLists.txt Implement del expression for SQL DELETE Apr 10, 2017
LICENSE.LGPL.txt Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
PostgresSchema.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
PostgresSchema.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
README.md Implement del expression for SQL DELETE Apr 10, 2017
SchemaUpdater.cpp Fixed #include casing Apr 9, 2014
SchemaUpdater.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
Sql.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlCondition.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlCondition.h Move condition related helpers to SqlCondition.h Apr 10, 2017
SqlConditionalQueryBuilderBase.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlConditionalQueryBuilderBase.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlCreateRule.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlCreateTable.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlCreateTable.h Build with Qt5 Apr 6, 2017
SqlDelete.h Implement del expression for SQL DELETE Apr 10, 2017
SqlDeleteQueryBuilder.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlDeleteQueryBuilder.h Implement del expression for SQL DELETE Apr 10, 2017
SqlExceptions.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlGlobal.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlGrantPermission.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlGraphviz.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlInsert.h Fix comment (copy/paste error) Apr 10, 2017
SqlInsertQueryBuilder.cpp Support for Default valued columns in SqlInsertQueryBuilder Oct 29, 2013
SqlInsertQueryBuilder.h Support for Default valued columns in SqlInsertQueryBuilder Oct 29, 2013
SqlInternals_p.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlMonitor.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlMonitor.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQuery.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQuery.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryBuilderBase.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryBuilderBase.h Add a insert().into... syntax, similar to select(...), and some quick… Oct 28, 2013
SqlQueryCache.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryCache.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryManager.cpp Build with Qt5 Apr 6, 2017
SqlQueryManager.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryWatcher.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlQueryWatcher.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlResources.qrc Use sqlate prefix for the resource Jul 2, 2013
SqlSchema.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlSchema.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlSchema_p.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlSelect.h Move condition related helpers to SqlCondition.h Apr 10, 2017
SqlSelectQueryBuilder.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlSelectQueryBuilder.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlTransaction.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlTransaction.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlUpdateQueryBuilder.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlUpdateQueryBuilder.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlUtils.cpp Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
SqlUtils.h Add full LGPL 2.1 text and add preamble to source headers. Aug 16, 2013
kdthreadrunner.cpp Build with Qt5 Apr 6, 2017
kdthreadrunner.h Build with Qt5 Apr 6, 2017
sqldetail.h Implement del expression for SQL DELETE Apr 10, 2017

README.md

SQLATE

Sqlate is a C++ library to interact with SQL databases that uses. It uses [Qt][https://www.qt.io] and advanced C++ templates that helps to write SQL queries in a type safe way, checked at compile time.

Main features

Table definitions

  • define tables as C++ structures
  • use C++ types to identify columns
  • get the SQL name from the C++ structure
TABLE( Presenters) {
    SQL_NAME( "presenters" );
    COLUMN( name, QString, NotNull );
    COLUMN( age, int, NotNull );
    COLUMN( company, QString);
    typedef boost::mpl::vector<nameType, ageType, companyType> columns;
};

Building queries

  • no need to refer to table and column names as strings
  • compile time checks for correctness

Query builders for INSERT, SELECT, DELETE, UPDATE, CREATE TABLE

SqlSelectQueryBuilder qb;
qb.setTable(Presenters);
qb.addColumn(Presenters.nam);
qb.whereCondition().addValueCondition( Presenters.age, SqlCondition::Equals, 42);
qb.whereCondition().addValueCondition( Presenters.company, SqlCondition::Equals,  “KDAB”);
QSqlQuery query = qb.exec();

Natural SQL syntax in C++ for SELECT, INSERT, DELETE (more to follow)

QSqlQuery query = select(Presenters.name).from(Presenters).where(Presenters.age == 42 && Presenters.company == “KDAB”);
...
QSqlQuery insertQuery = insert().into(Presenters).columns(Presenters.age << 22 & Presenters.company << "KDAB");
...
QSqlQuery deleteQuery = del().from(Presenters).where(Presenters.age == 42);

Other features

  • support complex join statements
  • transaction and monitor support
  • support for schema updates
  • extensible to support multiple database type and hides the SQL dialect difference from the end user (currently only PostgreSQL support is implemented)
  • exception based error handling

Prerequisites

  • CMake 3.2.0 or above
  • Qt 5.4 or above
  • Boost 1.40 or newer
  • Compiler supporting C++11/14
  • PostgreSQL (runtime dependency for unit tests)

Building from source

Linux

git clone git@github.com:KDAB/sqlate.git
cd sqlate
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=dest_dir
make
sudo make install

OSX, Windows and Android

  • the Qt 5 version was not tested on these systems as this moment. The Qt4 version works on these platforms, on Windows requiring MSVC 2010 or newer. For all systems the PostgreSQL Qt driver must be built and installed and Boost needs to be available. The Qt4 version can be found by checking out the qt4 branch.

Unit tests

To run unit tests use

ctest

in the build directory. For details about the unit test prerequisites, read the README.txt file in the tests directory.

License

  • LGPL v2.1

Sqlate is Copyright (C) 2011-2017 Klaralvdalens Datakonsult AB.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.