25 QString QgsExecutePostgisQueryAlgorithm::name()
const
27 return QStringLiteral(
"postgisexecutesql" );
30 QString QgsExecutePostgisQueryAlgorithm::displayName()
const
32 return QObject::tr(
"PostgreSQL execute SQL" );
35 QStringList QgsExecutePostgisQueryAlgorithm::tags()
const
37 return QObject::tr(
"database,sql,postgresql,postgis,execute" ).split(
',' );
40 QString QgsExecutePostgisQueryAlgorithm::group()
const
42 return QObject::tr(
"Database" );
45 QString QgsExecutePostgisQueryAlgorithm::groupId()
const
47 return QStringLiteral(
"database" );
50 QString QgsExecutePostgisQueryAlgorithm::shortHelpString()
const
52 return QObject::tr(
"Executes a SQL command on a PostgreSQL database." );
55 QgsExecutePostgisQueryAlgorithm *QgsExecutePostgisQueryAlgorithm::createInstance()
const
57 return new QgsExecutePostgisQueryAlgorithm();
60 void QgsExecutePostgisQueryAlgorithm::initAlgorithm(
const QVariantMap & )
70 QString connName = parameterAsConnectionName( parameters, QStringLiteral(
"DATABASE" ), context );
72 std::unique_ptr<QgsAbstractDatabaseProviderConnection> conn;
80 throw QgsProcessingException( QObject::tr(
"Could not retrieve connection details for %1" ).arg( connName ) );
83 QString sql = parameterAsString( parameters, QStringLiteral(
"SQL" ), context ).replace(
'\n',
' ' );
86 conn->executeSql( sql );