26 QString QgsExecuteSpatialiteQueryAlgorithm::name()
const
28 return QStringLiteral(
"spatialiteexecutesql" );
31 QString QgsExecuteSpatialiteQueryAlgorithm::displayName()
const
33 return QObject::tr(
"SpatiaLite execute SQL" );
36 QStringList QgsExecuteSpatialiteQueryAlgorithm::tags()
const
38 return QObject::tr(
"database,sql,spatialite,execute" ).split(
',' );
41 QString QgsExecuteSpatialiteQueryAlgorithm::group()
const
43 return QObject::tr(
"Database" );
46 QString QgsExecuteSpatialiteQueryAlgorithm::groupId()
const
48 return QStringLiteral(
"database" );
51 QString QgsExecuteSpatialiteQueryAlgorithm::shortHelpString()
const
53 return QObject::tr(
"Executes a SQL command on a SpatiaLite database." );
56 QgsExecuteSpatialiteQueryAlgorithm *QgsExecuteSpatialiteQueryAlgorithm::createInstance()
const
58 return new QgsExecuteSpatialiteQueryAlgorithm();
61 void QgsExecuteSpatialiteQueryAlgorithm::initAlgorithm(
const QVariantMap & )
70 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, QStringLiteral(
"DATABASE" ), context );
73 if ( uri.database().isEmpty() )
75 if ( databaseUri.contains( QStringLiteral(
"|layername" ), Qt::CaseInsensitive ) )
76 databaseUri = databaseUri.left( databaseUri.indexOf( QLatin1String(
"|layername" ) ) );
77 else if ( databaseUri.contains( QStringLiteral(
"|layerid" ), Qt::CaseInsensitive ) )
78 databaseUri = databaseUri.left( databaseUri.indexOf( QLatin1String(
"|layerid" ) ) );
80 uri =
QgsDataSourceUri( QStringLiteral(
"dbname='%1'" ).arg( databaseUri ) );
84 std::unique_ptr<QgsAbstractDatabaseProviderConnection> conn;
95 QString sql = parameterAsString( parameters, QStringLiteral(
"SQL" ), context ).replace(
'\n',
' ' );
98 conn->executeSql( sql );
105 return QVariantMap();
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
Class for storing the component parts of a RDBMS data source URI (e.g.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A string parameter for processing algorithms.
A vector layer (with or without geometry) parameter for processing algorithms.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
Custom exception class for provider connection related exceptions.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
Represents a vector layer which manages a vector based data sets.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.