comet.CQuery¶
- class comet.CQuery¶
This section describes all functions for the comet.CQuery class.
Methods¶
- CQuery.send(command)¶
Send an SQL instruction or parts of an SQL instruction. The SQL instructions should contain placeholders in place of input values. Placeholders for input values can be specified in two forms :
?
:1, :2, …
The first format is certainly the easier to use, but input values have be connected in the sequence of their application. If this is not possible, the second format can be used, input values will then be connected according to the numbering.
If strings are connected, no quotations marks need be inserted around the value placeholders. It is likewise not necessary to mask quotation marks in the strings.
All instructions sent with send are collected in the query and executed with
execute()
as one instruction. Following the execution of the instruction, the instruction buffer in the query is emptied. The connections to the entry values are likewise deleted following execution.- Parameters
command (str) – Instruction
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter command is empty.
CometError – On internal error
- Available
- CScript
- CQuery.input(value)¶
Connect an input variable to the corresponding placeholder in the command.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CQuery.output(type)¶
Define the output type for the next column of a select command. The output types must be given in the same order as the columns are returned from executing the command.
The provided types determine the types in the result tuple from
fetch()
It is not necessary to define all output columns, but if you want to receive the results of the n-th column, all the preceding n-th columns must be defined.
- Parameters
type (int) – The output type of the next column. One of Basic types
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter type is invalid.
CometError – On internal error
- Available
- CScript
- CQuery.execute(replaceBindings=True)¶
Send all command parts as one instruction. All value placeholders in the command are replaced by the defined input value and the command is executed. After the command is executed, the command buffer is emptied and all connections to the input values are deleted.
- Parameters
replaceBindings (bool) –
Replace placeholder markers before executing?
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CQuery.fetch()¶
Fetch the next line of the results of the command. This command is to be called in a loop, after each command from which a result is expected, until it returns False. After the last data has been fetched, the query can be used for the processing of another command.
- Returns
The loaded data from the command or
None
when no data is available.When the result is not
None
, the entries are returned in the order of the selected columns of the command as a list of tuples.Types in the tuples depend on the values provided by
output()
:comet.kInt
->int
comet.kString
->str
- Return type
- Raises
CometError – On internal error
- Available
- CQuery.commit(message='')¶
Confirm the changes of this query.
- Parameters
message (str) – Description for the command
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CQuery.rollback(message='')¶
Rollback the changes of this query.
- Parameters
message (str) – Description for the command
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CQuery.getCommand(replaceBindings=False)¶
Get the completed command which has been
send()
to this query but not yet executed.- Parameters
replaceBindings (bool) –
Replace placeholder markers inside the command by their current values?
- Returns
The prepared command
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript