Class: QgsSQLStatement

Parses SQL statements.

Class Hierarchy

Inheritance diagram of qgis.core.QgsSQLStatement

Subclasses

QgsSQLStatementFragment

Parses fragments of SQL statements, such as an expression or where clause.

Methods

acceptVisitor

Entry function for the visitor pattern

doBasicValidationChecks

Performs basic validity checks.

dump

Returns the 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

rootNode

Returns the root node of the statement.

statement

Returns the original, unmodified statement string.

Static Methods

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)

stripMsQuotedIdentifier

Remove double quotes from an Microsoft style identifier.

stripQuotedIdentifier

Remove double quotes from an identifier.

Attributes

boAnd

boConcat

boDiv

boEQ

boGE

boGT

boILike

boIntDiv

boIs

boIsNot

boLE

boLT

boLike

boMinus

boMod

boMul

boNE

boNotILike

boNotLike

boOr

boPlus

boPow

jtCross

jtDefault

jtFull

jtInner

jtLeft

jtLeftOuter

jtRight

jtRightOuter

ntBetweenOperator

ntBinaryOperator

ntCast

ntColumnRef

ntColumnSorted

ntFunction

ntInOperator

ntJoin

ntLiteral

ntSelect

ntSelectedColumn

ntTableDef

ntUnaryOperator

uoMinus

uoNot

class qgis.core.QgsSQLStatement[source]

Bases: object

__init__(statement: str | None)

Creates a new statement based on the provided string.

Parameters:

statement (Optional[str])

__init__(other: QgsSQLStatement)
Parameters:

other (QgsSQLStatement)

__init__(statement: str | None, allowFragments: bool)

Constructor for QgsSQLStatement, with the specified statement.

If allowFragments is True then the parser will allow SQL fragments, such as a expression or filter where clause alone.

Added in version 3.16.

Parameters:
  • statement (Optional[str])

  • allowFragments (bool)

class BinaryOperator

Bases: int

class JoinType

Bases: int

class Node[source]

Bases: object

Abstract node class for SQL statement nodes.

abstract accept(self, v: QgsSQLStatement.Visitor)[source]

Support the visitor pattern.

For any implementation this should look like

v.visit(self)
Parameters:

v (QgsSQLStatement.Visitor) – A visitor that visits this node.

abstract clone(self) QgsSQLStatement.Node | None[source]

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.

Return type:

Optional[QgsSQLStatement.Node]

Returns:

a deep copy of this node.

abstract dump(self) str[source]

Abstract virtual dump method

Return type:

str

Returns:

A statement which represents this node as string

abstract nodeType(self) QgsSQLStatement.NodeType[source]

Abstract virtual that returns the type of this node.

Return type:

QgsSQLStatement.NodeType

Returns:

The type of this node

class NodeBetweenOperator[source]

Bases: Node

An ‘X BETWEEN y and z’ operator.

QgsSQLStatement.NodeBetweenOperator(node: Optional[QgsSQLStatement.Node], minVal: Optional[QgsSQLStatement.Node], maxVal: Optional[QgsSQLStatement.Node], notBetween: bool = False) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

isNotBetween(self) bool[source]

Whether this is a NOT BETWEEN operator

Return type:

bool

maxVal(self) QgsSQLStatement.Node | None[source]

Maximum bound

Return type:

Optional[QgsSQLStatement.Node]

minVal(self) QgsSQLStatement.Node | None[source]

Minimum bound

Return type:

Optional[QgsSQLStatement.Node]

node(self) QgsSQLStatement.Node | None[source]

Variable at the left of BETWEEN

Return type:

Optional[QgsSQLStatement.Node]

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

class NodeBinaryOperator[source]

Bases: Node

Binary logical/arithmetical operator (AND, OR, =, +, …).

QgsSQLStatement.NodeBinaryOperator(op: QgsSQLStatement.BinaryOperator, opLeft: Optional[QgsSQLStatement.Node], opRight: Optional[QgsSQLStatement.Node]) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

leftAssociative(self) bool[source]

Is left associative ?

Return type:

bool

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

op(self) QgsSQLStatement.BinaryOperator[source]
opLeft(self) QgsSQLStatement.Node | None[source]

Left operand

Return type:

Optional[QgsSQLStatement.Node]

opRight(self) QgsSQLStatement.Node | None[source]

Right operand

Return type:

Optional[QgsSQLStatement.Node]

precedence(self) int[source]
class NodeCast[source]

Bases: Node

CAST operator.

QgsSQLStatement.NodeCast(node: Optional[QgsSQLStatement.Node], type: Optional[str]) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

node(self) QgsSQLStatement.Node | None[source]

Node that is referred to

Return type:

Optional[QgsSQLStatement.Node]

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

type(self) str[source]
class NodeColumnRef[source]

Bases: Node

Reference to a column.

QgsSQLStatement.NodeColumnRef(name: Optional[str], star: bool) Constructor with column name only

QgsSQLStatement.NodeColumnRef(tableName: Optional[str], name: Optional[str], star: bool) Constructor with table and column name

QgsSQLStatement.NodeColumnRef(a0: QgsSQLStatement.NodeColumnRef)

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

cloneThis(self) QgsSQLStatement.NodeColumnRef | None[source]

Clone with same type return

Return type:

Optional[QgsSQLStatement.NodeColumnRef]

distinct(self) bool[source]

Whether this is prefixed by DISTINCT

Return type:

bool

abstract dump(self) str[source]
Return type:

str

name(self) str[source]

The name of the column.

Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

setDistinct(self, distinct: bool = True)[source]

Sets whether this is prefixed by DISTINCT

Parameters:

distinct (bool = True)

star(self) bool[source]

Whether this is the * column

Return type:

bool

tableName(self) str[source]

The name of the table. May be empty.

Return type:

str

class NodeColumnSorted[source]

Bases: Node

Column in a ORDER BY.

QgsSQLStatement.NodeColumnSorted(column: Optional[QgsSQLStatement.NodeColumnRef], asc: bool) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

ascending(self) bool[source]

Whether the column is sorted in ascending order

Return type:

bool

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

cloneThis(self) QgsSQLStatement.NodeColumnSorted | None[source]

Clone with same type return

Return type:

Optional[QgsSQLStatement.NodeColumnSorted]

column(self) QgsSQLStatement.NodeColumnRef | None[source]

The name of the column.

Return type:

Optional[QgsSQLStatement.NodeColumnRef]

abstract dump(self) str[source]
Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

class NodeFunction[source]

Bases: Node

Function with a name and arguments node.

QgsSQLStatement.NodeFunction(name: Optional[str], args: Optional[QgsSQLStatement.NodeList]) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

args(self) QgsSQLStatement.NodeList | None[source]

Returns arguments

Return type:

Optional[QgsSQLStatement.NodeList]

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

name(self) str[source]

Returns function name

Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

class NodeInOperator[source]

Bases: Node

An ‘x IN (y, z)’ operator.

QgsSQLStatement.NodeInOperator(node: Optional[QgsSQLStatement.Node], list: Optional[QgsSQLStatement.NodeList], notin: bool = False) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

isNotIn(self) bool[source]

Whether this is a NOT IN operator

Return type:

bool

list(self) QgsSQLStatement.NodeList | None[source]

Values list

Return type:

Optional[QgsSQLStatement.NodeList]

node(self) QgsSQLStatement.Node | None[source]

Variable at the left of IN

Return type:

Optional[QgsSQLStatement.Node]

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

class NodeJoin[source]

Bases: Node

Join definition.

QgsSQLStatement.NodeJoin(tabledef: Optional[QgsSQLStatement.NodeTableDef], onExpr: Optional[QgsSQLStatement.Node], type: QgsSQLStatement.JoinType) Constructor with table definition, ON expression

QgsSQLStatement.NodeJoin(tabledef: Optional[QgsSQLStatement.NodeTableDef], usingColumns: Iterable[Optional[str]], type: QgsSQLStatement.JoinType) Constructor with table definition and USING columns

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

cloneThis(self) QgsSQLStatement.NodeJoin | None[source]

Clone with same type return

Return type:

Optional[QgsSQLStatement.NodeJoin]

abstract dump(self) str[source]
Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

onExpr(self) QgsSQLStatement.Node | None[source]

On expression. Will be None if usingColumns() is not empty

Return type:

Optional[QgsSQLStatement.Node]

tableDef(self) QgsSQLStatement.NodeTableDef | None[source]

Table definition

Return type:

Optional[QgsSQLStatement.NodeTableDef]

type(self) QgsSQLStatement.JoinType[source]

Join type

Return type:

QgsSQLStatement.JoinType

usingColumns(self) List[str]

Columns referenced by USING

Return type:

List[str]

class NodeList[source]

Bases: object

A list of nodes.

accept(self, v: QgsSQLStatement.Visitor)[source]

Accept visitor

Parameters:

v (QgsSQLStatement.Visitor)

append(self, node: QgsSQLStatement.Node | None)[source]

Takes ownership of the provided node

Parameters:

node (Optional[QgsSQLStatement.Node])

clone(self) QgsSQLStatement.NodeList | None[source]

Creates a deep copy of this list. Ownership is transferred to the caller

Return type:

Optional[QgsSQLStatement.NodeList]

count(self) int[source]

Returns the number of nodes in the list.

Return type:

int

virtual dump(self) str[source]

Dump list

Return type:

str

list(self) List[QgsSQLStatement.Node]

Returns list

Return type:

List[QgsSQLStatement.Node]

class NodeLiteral[source]

Bases: Node

Literal value (integer, integer64, double, string).

QgsSQLStatement.NodeLiteral(value: Any) Constructor

QgsSQLStatement.NodeLiteral(a0: QgsSQLStatement.NodeLiteral)

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

value(self) Any[source]

The value of the literal.

Return type:

Any

class NodeSelect[source]

Bases: Node

SELECT node.

QgsSQLStatement.NodeSelect(tableList: Iterable[QgsSQLStatement.NodeTableDef], columns: Iterable[QgsSQLStatement.NodeSelectedColumn], distinct: bool) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

appendJoin(self, join: QgsSQLStatement.NodeJoin | None)[source]

Append a join

Parameters:

join (Optional[QgsSQLStatement.NodeJoin])

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

columns(self) List[QgsSQLStatement.NodeSelectedColumn]

Returns the list of columns

Return type:

List[QgsSQLStatement.NodeSelectedColumn]

distinct(self) bool[source]

Returns if the SELECT is DISTINCT

Return type:

bool

abstract dump(self) str[source]
Return type:

str

joins(self) List[QgsSQLStatement.NodeJoin]

Returns the list of joins

Return type:

List[QgsSQLStatement.NodeJoin]

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

orderBy(self) List[QgsSQLStatement.NodeColumnSorted]

Returns the list of order by columns

Return type:

List[QgsSQLStatement.NodeColumnSorted]

setJoins(self, joins: Iterable[QgsSQLStatement.NodeJoin])[source]

Sets joins

Parameters:

joins (Iterable[QgsSQLStatement.NodeJoin])

setOrderBy(self, orderBy: Iterable[QgsSQLStatement.NodeColumnSorted])[source]

Sets order by columns

Parameters:

orderBy (Iterable[QgsSQLStatement.NodeColumnSorted])

setWhere(self, where: QgsSQLStatement.Node | None)[source]

Sets where clause

Parameters:

where (Optional[QgsSQLStatement.Node])

tables(self) List[QgsSQLStatement.NodeTableDef]

Returns the list of tables

Return type:

List[QgsSQLStatement.NodeTableDef]

where(self) QgsSQLStatement.Node | None[source]

Returns the where clause

Return type:

Optional[QgsSQLStatement.Node]

class NodeSelectedColumn[source]

Bases: Node

Selected column.

QgsSQLStatement.NodeSelectedColumn(node: Optional[QgsSQLStatement.Node]) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

alias(self) str[source]

Alias name

Return type:

str

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

cloneThis(self) QgsSQLStatement.NodeSelectedColumn | None[source]

Clone with same type return

Return type:

Optional[QgsSQLStatement.NodeSelectedColumn]

column(self) QgsSQLStatement.Node | None[source]

Column that is referred to

Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

setAlias(self, alias: str | None)[source]

Sets alias name

Parameters:

alias (Optional[str])

class NodeTableDef[source]

Bases: Node

Table definition.

QgsSQLStatement.NodeTableDef(name: Optional[str]) Constructor with table name

QgsSQLStatement.NodeTableDef(name: Optional[str], alias: Optional[str]) Constructor with table name and alias

QgsSQLStatement.NodeTableDef(schema: Optional[str], name: Optional[str], alias: Optional[str]) Constructor with schema, table name and alias

Added in version 3.28.

QgsSQLStatement.NodeTableDef(a0: QgsSQLStatement.NodeTableDef)

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

alias(self) str[source]

Table alias

Return type:

str

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

cloneThis(self) QgsSQLStatement.NodeTableDef | None[source]

Clone with same type return

Return type:

Optional[QgsSQLStatement.NodeTableDef]

abstract dump(self) str[source]
Return type:

str

name(self) str[source]

Table name

Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

schema(self) str[source]

Returns the schema name.

Added in version 3.28.

Return type:

str

class NodeType

Bases: int

class NodeUnaryOperator[source]

Bases: Node

Unary logical/arithmetical operator ( NOT, - ).

QgsSQLStatement.NodeUnaryOperator(op: QgsSQLStatement.UnaryOperator, operand: Optional[QgsSQLStatement.Node]) Constructor

abstract accept(self, v: QgsSQLStatement.Visitor)[source]
Parameters:

v (QgsSQLStatement.Visitor)

abstract clone(self) QgsSQLStatement.Node | None[source]
Return type:

Optional[QgsSQLStatement.Node]

abstract dump(self) str[source]
Return type:

str

abstract nodeType(self) QgsSQLStatement.NodeType[source]
Return type:

QgsSQLStatement.NodeType

op(self) QgsSQLStatement.UnaryOperator[source]
operand(self) QgsSQLStatement.Node | None[source]
class RecursiveVisitor[source]

Bases: Visitor

A visitor that recursively explores all children.

abstract visit(self, n: QgsSQLStatement.NodeUnaryOperator)[source]
abstract visit(self, n: QgsSQLStatement.NodeBinaryOperator) None
abstract visit(self, n: QgsSQLStatement.NodeInOperator) None
abstract visit(self, n: QgsSQLStatement.NodeBetweenOperator) None
abstract visit(self, n: QgsSQLStatement.NodeFunction) None
abstract visit(self, a0: QgsSQLStatement.NodeLiteral) None
abstract visit(self, a0: QgsSQLStatement.NodeColumnRef) None
abstract visit(self, n: QgsSQLStatement.NodeSelectedColumn) None
abstract visit(self, a0: QgsSQLStatement.NodeTableDef) None
abstract visit(self, n: QgsSQLStatement.NodeSelect) None
abstract visit(self, n: QgsSQLStatement.NodeJoin) None
abstract visit(self, n: QgsSQLStatement.NodeColumnSorted) None
abstract visit(self, n: QgsSQLStatement.NodeCast) None
Parameters:

n (QgsSQLStatement.NodeUnaryOperator)

abstract visit(self, n: QgsSQLStatement.NodeBinaryOperator)[source]
Parameters:

n (QgsSQLStatement.NodeBinaryOperator)

abstract visit(self, n: QgsSQLStatement.NodeInOperator)[source]
Parameters:

n (QgsSQLStatement.NodeInOperator)

abstract visit(self, n: QgsSQLStatement.NodeBetweenOperator)[source]
Parameters:

n (QgsSQLStatement.NodeBetweenOperator)

abstract visit(self, n: QgsSQLStatement.NodeFunction)[source]
Parameters:

n (QgsSQLStatement.NodeFunction)

abstract visit(self, a0: QgsSQLStatement.NodeLiteral)[source]
Parameters:

a0 (QgsSQLStatement.NodeLiteral)

abstract visit(self, a0: QgsSQLStatement.NodeColumnRef)[source]
Parameters:

a0 (QgsSQLStatement.NodeColumnRef)

abstract visit(self, n: QgsSQLStatement.NodeSelectedColumn)[source]
Parameters:

n (QgsSQLStatement.NodeSelectedColumn)

abstract visit(self, a0: QgsSQLStatement.NodeTableDef)[source]
Parameters:

a0 (QgsSQLStatement.NodeTableDef)

abstract visit(self, n: QgsSQLStatement.NodeSelect)[source]
Parameters:

n (QgsSQLStatement.NodeSelect)

abstract visit(self, n: QgsSQLStatement.NodeJoin)[source]
Parameters:

n (QgsSQLStatement.NodeJoin)

abstract visit(self, n: QgsSQLStatement.NodeColumnSorted)[source]
Parameters:

n (QgsSQLStatement.NodeColumnSorted)

abstract visit(self, n: QgsSQLStatement.NodeCast)[source]
Parameters:

n (QgsSQLStatement.NodeCast)

class UnaryOperator

Bases: int

class Visitor[source]

Bases: object

Support for visitor pattern - algorithms dealing with the statement may be implemented without modifying the Node classes.

abstract visit(self, n: QgsSQLStatement.NodeUnaryOperator)[source]

Visit NodeUnaryOperator

Parameters:

n (QgsSQLStatement.NodeUnaryOperator)

abstract visit(self, n: QgsSQLStatement.NodeBinaryOperator)[source]

Visit NodeBinaryOperator

Parameters:

n (QgsSQLStatement.NodeBinaryOperator)

abstract visit(self, n: QgsSQLStatement.NodeInOperator)[source]

Visit NodeInOperator

Parameters:

n (QgsSQLStatement.NodeInOperator)

abstract visit(self, n: QgsSQLStatement.NodeBetweenOperator)[source]

Visit NodeBetweenOperator

Parameters:

n (QgsSQLStatement.NodeBetweenOperator)

abstract visit(self, n: QgsSQLStatement.NodeFunction)[source]

Visit NodeFunction

Parameters:

n (QgsSQLStatement.NodeFunction)

abstract visit(self, n: QgsSQLStatement.NodeLiteral)[source]

Visit NodeLiteral

Parameters:

n (QgsSQLStatement.NodeLiteral)

abstract visit(self, n: QgsSQLStatement.NodeColumnRef)[source]

Visit NodeColumnRef

Parameters:

n (QgsSQLStatement.NodeColumnRef)

abstract visit(self, n: QgsSQLStatement.NodeSelectedColumn)[source]

Visit NodeSelectedColumn

Parameters:

n (QgsSQLStatement.NodeSelectedColumn)

abstract visit(self, n: QgsSQLStatement.NodeTableDef)[source]

Visit NodeTableDef

Parameters:

n (QgsSQLStatement.NodeTableDef)

abstract visit(self, n: QgsSQLStatement.NodeSelect)[source]

Visit NodeSelect

Parameters:

n (QgsSQLStatement.NodeSelect)

abstract visit(self, n: QgsSQLStatement.NodeJoin)[source]

Visit NodeJoin

Parameters:

n (QgsSQLStatement.NodeJoin)

abstract visit(self, n: QgsSQLStatement.NodeColumnSorted)[source]

Visit NodeColumnSorted

Parameters:

n (QgsSQLStatement.NodeColumnSorted)

abstract visit(self, n: QgsSQLStatement.NodeCast)[source]

Visit NodeCast

Parameters:

n (QgsSQLStatement.NodeCast)

acceptVisitor(self, v: QgsSQLStatement.Visitor)[source]

Entry function for the visitor pattern

Parameters:

v (QgsSQLStatement.Visitor)

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)[source]

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[source]

Returns the 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.

Return type:

str

hasParserError(self) bool[source]

Returns True if an error occurred when parsing the input statement

Return type:

bool

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[source]

Returns parser error

Return type:

str

static quotedIdentifier(name: str | None) str[source]

Returns a quoted column reference (in double quotes)

See also

quotedString()

Parameters:

name (Optional[str])

Return type:

str

static quotedIdentifierIfNeeded(name: str | None) str[source]

Returns a quoted column reference (in double quotes) if needed, or otherwise the original string.

See also

quotedString()

Parameters:

name (Optional[str])

Return type:

str

static quotedString(text: str | None) str[source]

Returns a quoted version of a string (in single quotes)

Parameters:

text (Optional[str])

Return type:

str

rootNode(self) QgsSQLStatement.Node | None[source]

Returns the root node of the statement. The root node is None if parsing has failed.

Return type:

Optional[QgsSQLStatement.Node]

statement(self) str[source]

Returns 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.

Return type:

str

static stripMsQuotedIdentifier(text: str | None) str[source]

Remove double quotes from an Microsoft style identifier.

Parameters:

text (Optional[str])

Return type:

str

static stripQuotedIdentifier(text: str | None) str[source]

Remove double quotes from an identifier.

Parameters:

text (Optional[str])

Return type:

str

uoMinus = 1
uoNot = 0