Skip to content
Permalink
Browse files

Add sqlite3_database_unique_ptr::exec (initial author: Matthias Kuhn …

…<matthias@opengis.ch>)

Partial backport of 49d8060
needed to backport e19bf11
  • Loading branch information
rouault committed Feb 6, 2019
1 parent 7aca6af commit 76c48e66dd5d5f5dbd4a0d5be935339f0baa9d4d
Showing with 27 additions and 1 deletion.
  1. +15 −0 src/core/qgssqliteutils.cpp
  2. +12 −1 src/core/qgssqliteutils.h
@@ -91,6 +91,21 @@ sqlite3_statement_unique_ptr sqlite3_database_unique_ptr::prepare( const QString
return s;
}

int sqlite3_database_unique_ptr::exec( const QString &sql, QString &errorMessage ) const
{
char *errMsg;

int ret = sqlite3_exec( get(), sql.toUtf8(), nullptr, nullptr, &errMsg );

if ( errMsg )
{
errorMessage = QString::fromUtf8( errMsg );
sqlite3_free( errMsg );
}

return ret;
}

QString QgsSqliteUtils::quotedString( const QString &value )
{
if ( value.isNull() )
@@ -21,6 +21,8 @@
#define SIP_NO_FILE

#include "qgis_core.h"
#include "qgis_sip.h"

#include <memory>
#include <QString>

@@ -134,8 +136,17 @@ class CORE_EXPORT sqlite3_database_unique_ptr : public std::unique_ptr< sqlite3,
* Prepares a \a sql statement, returning the result. The \a resultCode
* argument will be filled with the sqlite3 result code.
*/
sqlite3_statement_unique_ptr prepare( const QString &sql, int &resultCode ) const;
sqlite3_statement_unique_ptr prepare( const QString &sql, int &resultCode SIP_OUT ) const;

/**
* Executes the \a sql command in the database. Multiple sql queries can be run within
* one single command.
* Errors are reported to \a errorMessage.
* Returns SQLITE_OK in case of success or an sqlite error code.
*
* \since QGIS 3.4.5
*/
int exec( const QString &sql, QString &errorMessage SIP_OUT ) const;
};

/**

0 comments on commit 76c48e6

Please sign in to comment.
You can’t perform that action at this time.