diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /Plugins/DbSqlite2/dbsqlite2.cpp | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'Plugins/DbSqlite2/dbsqlite2.cpp')
| -rw-r--r-- | Plugins/DbSqlite2/dbsqlite2.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Plugins/DbSqlite2/dbsqlite2.cpp b/Plugins/DbSqlite2/dbsqlite2.cpp new file mode 100644 index 0000000..8047c7e --- /dev/null +++ b/Plugins/DbSqlite2/dbsqlite2.cpp @@ -0,0 +1,51 @@ +#include "dbsqlite2.h" +#include "dbsqlite2instance.h" +#include "common/unused.h" +#include <QFileInfo> + +DbSqlite2::DbSqlite2() +{ +} + +Db* DbSqlite2::getInstance(const QString& name, const QString& path, const QHash<QString, QVariant>& options, QString* errorMessage) +{ + UNUSED(errorMessage); + Db* db = new DbSqlite2Instance(name, path, options); + + if (!db->openForProbing()) + { + delete db; + return nullptr; + } + + SqlQueryPtr results = db->exec("SELECT * FROM sqlite_master"); + if (results->isError()) + { + delete db; + return nullptr; + } + + db->closeQuiet(); + return db; +} + +QList<DbPluginOption> DbSqlite2::getOptionsList() const +{ + return QList<DbPluginOption>(); +} + +QString DbSqlite2::generateDbName(const QVariant& baseValue) +{ + QFileInfo file(baseValue.toString()); + return file.baseName(); +} + +QString DbSqlite2::getLabel() const +{ + return "SQLite 2"; +} + +bool DbSqlite2::checkIfDbServedByPlugin(Db* db) const +{ + return (db && dynamic_cast<DbSqlite2Instance*>(db)); +} |
