diff options
| author | 2017-02-09 04:36:04 -0500 | |
|---|---|---|
| committer | 2017-02-09 04:36:04 -0500 | |
| commit | d9aa870e5d509cc7309ab82dd102a937ab58613a (patch) | |
| tree | d92d03d76b5c390b335f1cfd761f1a0b59ec8496 /Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp | |
| parent | 68ee4cbcbe424b95969c70346283a9f217f63825 (diff) | |
Imported Upstream version 3.1.1+dfsg1upstream/3.1.1+dfsg1
Diffstat (limited to 'Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp')
| -rw-r--r-- | Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp b/Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp new file mode 100644 index 0000000..2295006 --- /dev/null +++ b/Plugins/DbSqliteSystemData/dbsqlitesystemdatainstance.cpp @@ -0,0 +1,31 @@ +#include "dbsqlitesystemdatainstance.h"
+#include "dbsqlitesystemdata.h"
+
+DbSqliteSystemDataInstance::DbSqliteSystemDataInstance(const QString& name, const QString& path, const QHash<QString, QVariant>& connOptions) :
+ AbstractDb3<SystemDataSQLite>(name, path, connOptions)
+{
+}
+
+void DbSqliteSystemDataInstance::initAfterOpen()
+{
+ SqlQueryPtr res;
+
+ QString key = connOptions[DbSqliteSystemData::PASSWORD_OPT].toString();
+ if (!key.isEmpty())
+ {
+ res = exec(QString("PRAGMA key = '%1';").arg(key), Flag::NO_LOCK);
+ if (res->isError())
+ qWarning() << "Error while defining WxSqlite3 key:" << res->getErrorText();
+ }
+
+ AbstractDb3<SystemDataSQLite>::initAfterOpen();
+}
+
+QString DbSqliteSystemDataInstance::getAttachSql(Db *otherDb, const QString &generatedAttachName)
+{
+ QString pass = "";
+ if (otherDb->getConnectionOptions().contains(DbSqliteSystemData::PASSWORD_OPT))
+ pass = otherDb->getConnectionOptions()[DbSqliteSystemData::PASSWORD_OPT].toString().replace("'", "''");
+
+ return QString("ATTACH '%1' AS %2 KEY '%3';").arg(otherDb->getPath(), generatedAttachName, pass);
+}
|
