Herunterladen als
root/src/database.h @ 14f9beed
81c23b56 | Christian Ehringfeld | /*
|
|
6899f814 | Christian Ehringfeld | * Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program 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 General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
81c23b56 | Christian Ehringfeld | ||
#ifndef DATABASE_H
|
|||
#define DATABASE_H
|
|||
#include <QtSql/QSqlDatabase>
|
|||
#include <QtSql/QSqlDriver>
|
|||
#include <QtSql/QSqlQuery>
|
|||
#include <QDebug>
|
|||
#include <QtSql/QSqlError>
|
|||
#include <QStringList>
|
|||
#include <QList>
|
|||
#include <QString>
|
|||
#include <QDebug>
|
|||
#include "enums/databasetype.h"
|
|||
6899f814 | Christian Ehringfeld | namespace CuteEntityManager {
|
|
81c23b56 | Christian Ehringfeld | ||
426974c6 | Christian Ehringfeld | class Database {
|
|
private:
|
|||
81c23b56 | Christian Ehringfeld | QSqlDatabase database;
|
|
QString connectionName;
|
|||
bool seqTable;
|
|||
bool supportTransactions;
|
|||
void init();
|
|||
426974c6 | Christian Ehringfeld | protected:
|
|
caea9141 | Christian Ehringfeld | // inline QString pgsqlSeqTable();
|
|
// inline QString mysqlSeqTable();
|
|||
// inline QString sqliteSeqTable();
|
|||
// inline QString sqliteTableList();
|
|||
// inline QString mysqlTableList();
|
|||
// inline QString pgsqlTableList();
|
|||
81c23b56 | Christian Ehringfeld | ||
426974c6 | Christian Ehringfeld | public:
|
|
81c23b56 | Christian Ehringfeld | Database(QSqlDatabase database);
|
|
~Database();
|
|||
Database(QString databaseType, QString databasename);
|
|||
Database(QString databaseType, QString connectionName, QString databasename);
|
|||
426974c6 | Christian Ehringfeld | Database(QString databaseType, QString connectionName = "", QString hostname = "", QString databasename = "" ,
|
|
QString username = "", QString password = "", qint64 port = 0);
|
|||
81c23b56 | Christian Ehringfeld | QSqlDatabase getDatabase();
|
|
QString getConnectionName();
|
|||
QSqlQuery getQuery();
|
|||
QSqlQuery getQuery(const QString &prepare);
|
|||
bool transaction(const QString &query);
|
|||
bool transaction(const QStringList &queries);
|
|||
bool transaction(QSqlQuery &query);
|
|||
bool transaction(QList<QSqlQuery> &queries);
|
|||
bool exec(QString query);
|
|||
bool exec(QStringList queries);
|
|||
bool exec(QSqlQuery query);
|
|||
bool exec(QList<QSqlQuery> queries);
|
|||
bool select(QSqlQuery &query);
|
|||
QSqlQuery select(const QString &query);
|
|||
14f9beed | Christian Ehringfeld | // bool isSeqTable();
|
|
// qint64 getLastId();
|
|||
// void getTableListFromDatabase();
|
|||
// void setTableList(QSqlQuery &q);
|
|||
// void refreshTableList();
|
|||
// QChar escapeChar();
|
|||
81c23b56 | Christian Ehringfeld | };
|
|
}
|
|||
#endif // DATABASE_H
|