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.
TABLE( Presenters) {
SQL_NAME( "presenters" );
COLUMN( name, QString, NotNull );
COLUMN( age, int, NotNull );
COLUMN( company, QString);
typedef boost::mpl::vector<nameType, ageType, companyType> columns;
};
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();
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);
git clone git@github.com:KDAB/sqlate.git
cd sqlate
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=dest_dir
make
sudo make install
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.
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.