SPARQL Query Builder
builder
Aggregate
And
AskClause
AskQuery
AtomicGraphPattern
BNODE
BOUND
BinaryBuiltInCall
Bind
BooleanExpression
BuiltInCall
COALESCE
COUNT
COUNT_STAR
Call
Clause
Coerce
Type-checking and coercion functions.
Comment
CommentsBlock
CompoundGraphPattern
Encodable
Equal
Expression
Filter
FilterNotExistsGraphPattern
GraphPattern
GreaterThan
GreaterThanOrEqual
GroupGraphPattern
IF
IsBlank
IsLiteral
Bases: UnaryBuiltInCall
The isLiteral built-in.
See https://www.w3.org/TR/sparql11-query/#func-isLiteral.
IsURI
LANG
LessThan
LessThanOrEqual
LimitClause
LogicExpression
NamedSubSelectBlock
Bases: SubSelectBlock
Named sub-select block.
This is an extension supported by Blazegraph.
See https://github.com/blazegraph/database/wiki/NamedSubquery.
Not
NotEqual
NumericExpression
NumericLiteral
OffsetClause
OptionalGraphPattern
Or
OrderByClause
Pattern
Query
Bases: Encodable
Abstract base class for queries.
limit
property
writable
The value of the LIMIT modifier.
offset
property
writable
The value of the OFFSET modifier.
order_by
property
writable
The value of the ORDER BY modifier.
ask(limit=None, offset=None, fresh_var_prefix=None, fresh_var_counter=None, deepcopy=True)
Converts query to an ASK query.
Parameters:
-
limit(int | None, default:None) –Limit.
-
offset(int | None, default:None) –Offset.
-
fresh_var_prefix(_str | None, default:None) –Prefix of fresh variables.
-
deepcopy(bool, default:True) –Whether to deep-copy the common clauses.
Returns:
-
AskQuery–class:
AskQuery.
begin_filter_not_exists()
Pushes FILTER NOT EXISTS graph pattern.
Returns:
-
FilterNotExistsGraphPattern–class:
FilterNotExistsGraphPattern.
begin_group()
begin_optional()
begin_union()
bind(expression, variable)
Pushes BIND.
Parameters:
-
expression(TExpression) –Expression.
-
variable(TVariable) –Variable.
Returns:
-
Query–class:
Query.
bnode()
classmethod
Constructs :class:BNode.
Returns:
-
BNode–class:
BNode.
clear_user_data()
Clears user-data attached to query.
comments()
end_filter_not_exists()
Pops FILTER NOT EXISTS graph pattern.
Returns:
-
FilterNotExistsGraphPattern–class:
FilterNotExistsGraphPattern.
end_group()
end_optional()
end_union()
filter(expression)
filter_not_exists()
Constructs FILTER NOT EXISTS graph pattern.
Returns:
-
FilterNotExistsGraphPattern–class:
FilterNotExistsGraphPatternowned by clause.
fresh_var()
Constructs fresh variable.
Returns:
-
Variable–class:
Variable.
fresh_vars(n)
get_limit()
get_offset()
get_order_by()
Gets the value of the ORDER BY modifier.
Returns:
-
Expression | None–Order by expression.
get_user_data(key)
Gets the user-data value attached to key in query.
Parameters:
-
key(str) –Key.
Returns:
-
Any–Value or
None.
group()
Constructs group graph pattern.
Returns:
-
GroupGraphPattern–class:
GroupGraphPatternowned by clause.
literal(content, language=None, datatype=None)
classmethod
Constructs :class:Literal.
Parameters:
-
content(TLiteral) –Literal content.
-
language(str | None, default:None) –Literal language.
-
datatype(str | None, default:None) –Literal datatype.
Returns:
-
Literal–class:
Literal.
named_subquery(name, query)
Constructs a named sub-select block.
Returns:
-
NamedSubSelectBlock–class:
NamedSubSelectBlockowned by clause.
optional()
Constructs OPTIONAL graph pattern.
Returns:
-
OptionalGraphPattern–class:
OptionalGraphPatternowned by clause.
optional_if(condition)
Constructs OPTIONAL or graph pattern depending on condition.
Parameters:
-
condition(bool) –Boolean condition.
Returns:
-
OptionalGraphPattern | GroupGraphPattern–class:
OptionalGraphPatternifconditionisTrue; -
OptionalGraphPattern | GroupGraphPattern–class:
GroupGraphPatternotherwise.
select(*variables, distinct=None, reduced=None, limit=None, offset=None, order_by=None, fresh_var_prefix=None, fresh_var_counter=None, deepcopy=True)
Converts query to a SELECT query.
Parameters:
-
variables(TVariable | TInlineBind, default:()) –Variables or inline binds.
-
distinct(bool | None, default:None) –Whether to enable distinct modifier.
-
reduced(bool | None, default:None) –Whether to enable reduced modifier.
-
limit(int | None, default:None) –Limit.
-
offset(int | None, default:None) –Offset.
-
order_by(TExpression | None, default:None) –Order-by expression.
-
fresh_var_prefix(_str | None, default:None) –Prefix of fresh variables.
-
deepcopy(bool, default:True) –Whether to deep-copy the common clauses.
Returns:
-
SelectQuery–class:
SelectQuery.
set_limit(limit)
set_offset(offset)
set_order_by(expression)
Sets the value of the ORDER BY modifier.
Parameters:
-
expression(TExpression | None) –Expression or
None.
set_user_data(key, value)
Attaches user-data value to key in query.
Parameters:
-
key(str) –Key.
-
value(T) –Value.
Returns:
-
T–value.
subquery(query)
triples()
union()
Constructs UNION graph pattern.
Returns:
-
UnionGraphPattern–class:
UnionGraphPatternowned by clause.
unset_user_data(key)
Detaches user-data value from key in query.
Parameters:
-
key(str) –Key.
Returns:
-
Any–The detached value or
None.
uri(content)
classmethod
Constructs :class:URIRef.
Parameters:
-
content(T_URI) –URI content.
Returns:
-
URIRef–class:
URIRef.
values(*variables)
Constructs VALUES block
Parameters:
-
variables(TVariable, default:()) –Variables.
Returns:
-
ValuesBlock–class:
ValuesBlockowned by clause.
var(name)
classmethod
Constructs :class:Variable.
Parameters:
-
name(TVariable) –Variable name.
Returns:
-
Variable–class:
Variable.
vars(name, *names)
classmethod
Constructs one or more variables.
Parameter
name: Variable name. names: Variable names.
Returns:
-
Iterator[Variable]–Iterator of :class:
Variable.
where_is_empty()
Tests whether the WHERE clause of query is empty.
Returns:
-
bool–Trueif successful;Falseotherwise.
where_is_nonempty()
Tests whether the WHERE clause of query is nonempty.
Returns:
-
bool–Trueif successful;Falseotherwise.
RelationalExpression
STR
STRDT
STRLANG
Bases: BinaryBuiltInCall
The STRLANG built-in.
See https://www.w3.org/TR/sparql11-query/#func-strlang.
STRSTARTS
Bases: BinaryBuiltInCall
The STRSTARTS built-in.
See https://www.w3.org/TR/sparql11-query/#func-strstarts.
SelectClause
SelectQuery
Bases: Query
SELECT query.
distinct
property
writable
The DISTINCT modifier.
reduced
property
writable
The REDUCED modifier.
SubSelectBlock
Symbol
Symbol table.