Subgroup: S
Class: QgsSQLStatement¶
-
class
qgis.core.
QgsSQLStatement
¶ Bases:
sip.wrapper
Class for parsing SQL statements.
New in version 2.16: Methods
acceptVisitor
Entry function for the visitor pattern doBasicValidationChecks
Performs basic validity checks. dump
Return statement string, constructed from the internal abstract syntax tree. hasParserError
Returns true if an error occurred when parsing the input statement parserErrorString
Returns parser error quotedIdentifier
Returns a quoted column reference (in double quotes) quotedIdentifierIfNeeded
Returns a quoted column reference (in double quotes) if needed, or otherwise the original string. quotedString
Returns a quoted version of a string (in single quotes) rootNode
Returns root node of the statement. statement
Return the original, unmodified statement string. stripQuotedIdentifier
Remove double quotes from an identifier. Attributes
-
class
BinaryOperator
¶ Bases:
int
-
class
JoinType
¶ Bases:
int
-
class
Node
¶ Bases:
sip.wrapper
Abstract node class *
-
accept
(self, v: QgsSQLStatement.Visitor)¶ Support the visitor pattern.
For any implementation this should look like
C++:
v.visit( *this );
Python:
v.visit( self)
Parameters: v – A visitor that visits this node.
-
clone
(self) → QgsSQLStatement.Node¶ Generate a clone of this node. Make sure that the clone does not contain any information which is generated in prepare and context related. Ownership is transferred to the caller.
Returns: a deep copy of this node.
-
dump
(self) → str¶ Abstract virtual dump method
Returns: A statement which represents this node as string
-
nodeType
(self) → QgsSQLStatement.NodeType¶ Abstract virtual that returns the type of this node.
Returns: The type of this node
-
-
class
NodeBetweenOperator
¶ Bases:
qgis._core.Node
‘X BETWEEN y and z’ operator *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
isNotBetween
(self) → bool¶ Whether this is a NOT BETWEEN operator
-
maxVal
(self) → QgsSQLStatement.Node¶ Maximum bound
-
minVal
(self) → QgsSQLStatement.Node¶ Minimum bound
-
node
(self) → QgsSQLStatement.Node¶ Variable at the left of BETWEEN
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
-
class
NodeBinaryOperator
¶ Bases:
qgis._core.Node
Binary logical/arithmetical operator (AND, OR, =, +, …) *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
leftAssociative
(self) → bool¶ Is left associative ?
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
op
(self) → QgsSQLStatement.BinaryOperator¶ Operator
-
opLeft
(self) → QgsSQLStatement.Node¶ Left operand
-
opRight
(self) → QgsSQLStatement.Node¶ Right operand
-
precedence
(self) → int¶ Precedence
-
-
class
NodeCast
¶ Bases:
qgis._core.Node
CAST operator *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
node
(self) → QgsSQLStatement.Node¶ Node that is referred to
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
type
(self) → str¶ Type
-
-
class
NodeColumnRef
¶ Bases:
qgis._core.Node
Reference to a column *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
cloneThis
(self) → QgsSQLStatement.NodeColumnRef¶ Clone with same type return
-
distinct
(self) → bool¶ Whether this is prefixed by DISTINCT
-
dump
(self) → str¶
-
name
(self) → str¶ The name of the column.
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
setDistinct
(self, distinct: bool = True)¶ Set whether this is prefixed by DISTINCT
-
star
(self) → bool¶ Whether this is the * column
-
tableName
(self) → str¶ The name of the table. May be empty.
-
-
class
NodeColumnSorted
¶ Bases:
qgis._core.Node
Column in a ORDER BY *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
ascending
(self) → bool¶ Whether the column is sorted in ascending order
-
clone
(self) → QgsSQLStatement.Node¶
-
cloneThis
(self) → QgsSQLStatement.NodeColumnSorted¶ Clone with same type return
-
column
(self) → QgsSQLStatement.NodeColumnRef¶ The name of the column.
-
dump
(self) → str¶
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
-
class
NodeFunction
¶ Bases:
qgis._core.Node
Function with a name and arguments node *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
args
(self) → QgsSQLStatement.NodeList¶ Return arguments
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
name
(self) → str¶ Return function name
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
-
class
NodeInOperator
¶ Bases:
qgis._core.Node
‘x IN (y, z)’ operator *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
isNotIn
(self) → bool¶ Whether this is a NOT IN operator
-
list
(self) → QgsSQLStatement.NodeList¶ Values list
-
node
(self) → QgsSQLStatement.Node¶ Variable at the left of IN
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
-
class
NodeJoin
¶ Bases:
qgis._core.Node
Join definition *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
cloneThis
(self) → QgsSQLStatement.NodeJoin¶ Clone with same type return
-
dump
(self) → str¶
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
onExpr
(self) → QgsSQLStatement.Node¶ On expression. Will be None if usingColumns() is not empty
-
tableDef
(self) → QgsSQLStatement.NodeTableDef¶ Table definition
-
type
(self) → QgsSQLStatement.JoinType¶ Join type
-
usingColumns
(self) → List[str]¶ Columns referenced by USING
-
-
class
NodeList
¶ Bases:
sip.wrapper
List of nodes *
-
accept
(self, v: QgsSQLStatement.Visitor)¶ Accept visitor
-
append
(self, node: QgsSQLStatement.Node)¶ Takes ownership of the provided node
-
clone
(self) → QgsSQLStatement.NodeList¶ Creates a deep copy of this list. Ownership is transferred to the caller
-
count
(self) → int¶ Returns the number of nodes in the list.
-
dump
(self) → str¶ Dump list
-
list
(self) → object¶ Return list
-
-
class
NodeLiteral
¶ Bases:
qgis._core.Node
Literal value (integer, integer64, double, string) *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
value
(self) → Any¶ The value of the literal.
-
-
class
NodeSelect
¶ Bases:
qgis._core.Node
SELECT node *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
appendJoin
(self, join: QgsSQLStatement.NodeJoin)¶ Append a join
-
clone
(self) → QgsSQLStatement.Node¶
-
columns
(self) → List[QgsSQLStatement.NodeSelectedColumn]¶ Return the list of columns
-
distinct
(self) → bool¶ Return if the SELECT is DISTINCT
-
dump
(self) → str¶
-
joins
(self) → List[QgsSQLStatement.NodeJoin]¶ Return the list of joins
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
orderBy
(self) → List[QgsSQLStatement.NodeColumnSorted]¶ Return the list of order by columns
-
setJoins
(self, joins: object)¶ Set joins
-
setOrderBy
(self, orderBy: object)¶ Set order by columns
-
setWhere
(self, where: QgsSQLStatement.Node)¶ Set where clause
-
tables
(self) → List[QgsSQLStatement.NodeTableDef]¶ Return the list of tables
-
where
(self) → QgsSQLStatement.Node¶ Return the where clause
-
-
class
NodeSelectedColumn
¶ Bases:
qgis._core.Node
Selected column *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
alias
(self) → str¶ Alias name
-
clone
(self) → QgsSQLStatement.Node¶
-
cloneThis
(self) → QgsSQLStatement.NodeSelectedColumn¶ Clone with same type return
-
column
(self) → QgsSQLStatement.Node¶ Column that is referred to
-
dump
(self) → str¶
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
setAlias
(self, alias: str)¶ Set alias name
-
-
class
NodeTableDef
¶ Bases:
qgis._core.Node
Table definition *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
alias
(self) → str¶ Table alias
-
clone
(self) → QgsSQLStatement.Node¶
-
cloneThis
(self) → QgsSQLStatement.NodeTableDef¶ Clone with same type return
-
dump
(self) → str¶
-
name
(self) → str¶ Table name
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
-
class
NodeType
¶ Bases:
int
-
class
NodeUnaryOperator
¶ Bases:
qgis._core.Node
Unary logicial/arithmetical operator ( NOT, - ) *
-
accept
(self, v: QgsSQLStatement.Visitor)¶
-
clone
(self) → QgsSQLStatement.Node¶
-
dump
(self) → str¶
-
nodeType
(self) → QgsSQLStatement.NodeType¶
-
op
(self) → QgsSQLStatement.UnaryOperator¶ Operator
-
operand
(self) → QgsSQLStatement.Node¶ Operand
-
-
class
RecursiveVisitor
¶ Bases:
qgis._core.Visitor
A visitor that recursively explores all children *
-
visit
(self, n: QgsSQLStatement.NodeUnaryOperator)¶ visit(self, n: QgsSQLStatement.NodeBinaryOperator) visit(self, n: QgsSQLStatement.NodeInOperator) visit(self, n: QgsSQLStatement.NodeBetweenOperator) visit(self, n: QgsSQLStatement.NodeFunction) visit(self, QgsSQLStatement.NodeLiteral) visit(self, QgsSQLStatement.NodeColumnRef) visit(self, n: QgsSQLStatement.NodeSelectedColumn) visit(self, QgsSQLStatement.NodeTableDef) visit(self, n: QgsSQLStatement.NodeSelect) visit(self, n: QgsSQLStatement.NodeJoin) visit(self, n: QgsSQLStatement.NodeColumnSorted) visit(self, n: QgsSQLStatement.NodeCast)
-
-
class
UnaryOperator
¶ Bases:
int
-
class
Visitor
¶ Bases:
sip.wrapper
Support for visitor pattern - algorithms dealing with the statement may be implemented without modifying the Node classes *
-
visit
(self, n: QgsSQLStatement.NodeUnaryOperator)¶ Visit NodeUnaryOperator
visit(self, n: QgsSQLStatement.NodeBinaryOperator) Visit NodeBinaryOperator
visit(self, n: QgsSQLStatement.NodeInOperator) Visit NodeInOperator
visit(self, n: QgsSQLStatement.NodeBetweenOperator) Visit NodeBetweenOperator
visit(self, n: QgsSQLStatement.NodeFunction) Visit NodeFunction
visit(self, n: QgsSQLStatement.NodeLiteral) Visit NodeLiteral
visit(self, n: QgsSQLStatement.NodeColumnRef) Visit NodeColumnRef
visit(self, n: QgsSQLStatement.NodeSelectedColumn) Visit NodeSelectedColumn
visit(self, n: QgsSQLStatement.NodeTableDef) Visit NodeTableDef
visit(self, n: QgsSQLStatement.NodeSelect) Visit NodeSelect
visit(self, n: QgsSQLStatement.NodeJoin) Visit NodeJoin
visit(self, n: QgsSQLStatement.NodeColumnSorted) Visit NodeColumnSorted
visit(self, n: QgsSQLStatement.NodeCast) Visit NodeCast
-
-
acceptVisitor
(self, v: QgsSQLStatement.Visitor)¶ Entry function for the visitor pattern
-
boAnd
= 1¶
-
boConcat
= 21¶
-
boDiv
= 17¶
-
boEQ
= 2¶
-
boGE
= 5¶
-
boGT
= 7¶
-
boILike
= 10¶
-
boIntDiv
= 18¶
-
boIs
= 12¶
-
boIsNot
= 13¶
-
boLE
= 4¶
-
boLT
= 6¶
-
boLike
= 8¶
-
boMinus
= 15¶
-
boMod
= 19¶
-
boMul
= 16¶
-
boNE
= 3¶
-
boNotILike
= 11¶
-
boNotLike
= 9¶
-
boOr
= 0¶
-
boPlus
= 14¶
-
boPow
= 20¶
-
doBasicValidationChecks
(self) → Tuple[bool, str]¶ Performs basic validity checks. Basically checking that columns referencing a table, references a specified table. Returns true if the validation is successful *
-
dump
(self) → str¶ Return statement string, constructed from the internal abstract syntax tree. This does not contain any nice whitespace formatting or comments. In general it is preferable to use statement() instead.
-
hasParserError
(self) → bool¶ Returns true if an error occurred when parsing the input statement
-
jtCross
= 5¶
-
jtDefault
= 0¶
-
jtFull
= 7¶
-
jtInner
= 6¶
-
jtLeft
= 1¶
-
jtLeftOuter
= 2¶
-
jtRight
= 3¶
-
jtRightOuter
= 4¶
-
ntBetweenOperator
= 3¶
-
ntBinaryOperator
= 1¶
-
ntCast
= 12¶
-
ntColumnRef
= 6¶
-
ntColumnSorted
= 11¶
-
ntFunction
= 4¶
-
ntInOperator
= 2¶
-
ntJoin
= 10¶
-
ntLiteral
= 5¶
-
ntSelect
= 8¶
-
ntSelectedColumn
= 7¶
-
ntTableDef
= 9¶
-
ntUnaryOperator
= 0¶
-
parserErrorString
(self) → str¶ Returns parser error
-
quotedIdentifier
(name: str) → str¶ Returns a quoted column reference (in double quotes)
See also
-
quotedIdentifierIfNeeded
(name: str) → str¶ Returns a quoted column reference (in double quotes) if needed, or otherwise the original string.
See also
-
quotedString
(text: str) → str¶ Returns a quoted version of a string (in single quotes)
See also
-
rootNode
(self) → QgsSQLStatement.Node¶ Returns root node of the statement. Root node is null is parsing has failed
-
statement
(self) → str¶ Return the original, unmodified statement string. If there was none supplied because it was constructed by sole API calls, dump() will be used to create one instead.
-
stripQuotedIdentifier
(text: str) → str¶ Remove double quotes from an identifier.
See also
-
uoMinus
= 1¶
-
uoNot
= 0¶
-
class