Arena
1.0
A content management system
|
A basic SQL query executed against a data source. More...
Public Member Functions | |
def | __init__ |
Construct a new query instance that will operate on the specified data source. More... | |
def | init |
Initializer. | |
def | escapeString |
Escape special characters in the specified string so that it is safe for use with an SQL query. More... | |
def | quoteString |
Return the quoted form of the specified string, such that it is suitable for use with an SQL query. More... | |
def | processFormatValue |
Process a value contained within a format string. More... | |
def | formatString |
Format a query string for use with the data source. More... | |
def | quoteIdentifier |
Return the specified identifier, delimited with the special quotes used by the data source for identifiers. More... | |
def | implodeIdentifiersIn |
Implode the identifiers contained in the specified list, placing database-specific quotation marks around each one. More... | |
def | implodeValuesIn |
Implode the values in the specified list, escaping any string values that are found. More... | |
def | implodeFieldsIn |
Implode the fields and values in the specified dictionary object, quoting identifiers and escaping fields as appropriate. More... | |
def | processCriterionPlaceholder |
Process a placeholder from a criterion format string. More... | |
def | implodeCriteriaIn |
Implode the fields and values in the specified criteria list, quoting the identifiers and escaping (and quoting) the string values. More... | |
def | prepareQueryString |
Prepare the query string for submission to the data source. More... | |
def | toString |
Construct a string representation of the data source. More... | |
def | queryString |
Return the string used by the query. More... | |
Public Member Functions inherited from Library.DataSource.Queries.AQuery | |
def | __init__ |
Construct a new query instance that will operate on the specified data source. More... | |
def | init |
Initializer. | |
def | __del__ |
Destroy the query instance. More... | |
def | execute |
Execute the query. More... | |
def | nextRecord |
Retrieve the next row from the query. More... | |
def | recordCount |
Retrieve the number of rows affected or returned by the query. More... | |
def | Rows |
Return an iterator for the query that retrieves rows as instances of the specified row class. More... | |
def | __iter__ |
Return an iterator for the query. More... | |
def | __len__ |
Retrieve the "length" of the query – the number of rows returned. More... | |
Public Member Functions inherited from Library.DataSource.Databases.ADataOperation | |
def | __init__ |
Construct a new data operation that will operate on the specified data source. More... | |
def | init |
Initializer. | |
def | execute |
Execute the operation. More... | |
def | Source |
Retrieve the data source used by the operation. More... | |
def | handle |
Retrieve the handle assigned to the operation by the data source. More... | |
def | runtime |
Retrieve the amount of time elapsed while executing the operation. More... | |
def | result |
Retrieve the result code returned by the data source after executing the operation. More... | |
def | message |
Retrieve the message generated by the data source while executing the operation, if any. More... | |
Public Member Functions inherited from Library.Base.Events.ALoggingEventfulObject | |
def | __init__ |
Constructor. More... | |
def | init |
Initializer. | |
def | error |
Generate an error event. More... | |
def | log |
Log the specified item. More... | |
def | Log |
Retrieve the log used by the class. | |
Public Member Functions inherited from Library.Base.Events.AnEventfulObject | |
def | __init__ |
Constructor. More... | |
def | init |
Initializer. | |
def | __del__ |
Destructor. | |
def | parseParams |
Parse the specified parameters, looking for named events and setting event handlers as appropriate. More... | |
def | generate |
Generate the named event. | |
def | update |
Update the events generated by the object. | |
def | error |
Generate an error event. More... | |
def | toString |
Construct a string representation of the object. More... | |
def | on |
Set the handler for the specified event. More... | |
def | onMultiple |
Set handlers for multiple events. More... | |
def | handlerFor |
Retrieve the handler for the specified event. More... | |
def | generates |
Determine whether or not the object generates the named event. More... | |
def | __getitem__ |
Retrieve the value of the named property. | |
def | __setitem__ |
Set the value of the named property. | |
Public Member Functions inherited from Library.Base.Classwork.AnObject | |
def | init |
Initialize a new object instance. More... | |
def | __init__ |
Construct and initialize a new instance of AnObject. More... | |
def | __del__ |
Destroy the object instance. More... | |
def | displayName |
Construct a "pretty" display name for the class instance, based on the name of its class. More... | |
def | implements |
Determine whether the class instance is related to the specified class. More... | |
def | toString |
Return a string representation of the class, suitable for output to a console or text-based device. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | classname |
Return the name of the class from which the instance was created. More... | |
def | name |
Return the name of the class. More... | |
Public Member Functions inherited from Library.String.Utilities.IsPrintable | |
def | toString |
Return a string representation of the class conveniently. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | printTo |
Print a string representation of the class to the specified stream. More... | |
A basic SQL query executed against a data source.
Note that this class does not implement the execute() method inherited from ADataOperation and so it should not be instantiated directly.
def Plugins.DataSource.SQLQueries.AnSQLQuery.__init__ | ( | Self, | |
params | |||
) |
Construct a new query instance that will operate on the specified data source.
def Plugins.DataSource.SQLQueries.AnSQLQuery.escapeString | ( | Self, | |
thisString | |||
) |
Escape special characters in the specified string so that it is safe for use with an SQL query.
This routine calls String.escape() using #sqSpecialCharacters.
def Plugins.DataSource.SQLQueries.AnSQLQuery.formatString | ( | Self, | |
fmt, | |||
posValues, | |||
kwValues | |||
) |
Format a query string for use with the data source.
This routine attempts to harden the string against SQL injection attacks by passing all given string values to ADataSource.escapeString(). All values provided are converted to strings.
This routine is necessary because str.format() removes single-quote characters from string values as it processes them.
def Plugins.DataSource.SQLQueries.AnSQLQuery.implodeCriteriaIn | ( | Self, | |
thisList | |||
) |
Implode the fields and values in the specified criteria list, quoting the identifiers and escaping (and quoting) the string values.
Each criterion should be a simple expression of the form: identifier OPERATOR identifier
. The identifier
elements of the criterion can be a field name or a list of values.
Each criterion should be a list (or tuple), where the first item is a format string and the remaining items are the values to be inserted into the format string.
def Plugins.DataSource.SQLQueries.AnSQLQuery.implodeFieldsIn | ( | Self, | |
thisDict | |||
) |
Implode the fields and values in the specified dictionary object, quoting identifiers and escaping fields as appropriate.
def Plugins.DataSource.SQLQueries.AnSQLQuery.implodeIdentifiersIn | ( | Self, | |
thisList, | |||
itemsDelimiter = sqListDelimiter |
|||
) |
Implode the identifiers contained in the specified list, placing database-specific quotation marks around each one.
def Plugins.DataSource.SQLQueries.AnSQLQuery.implodeValuesIn | ( | Self, | |
thisList, | |||
itemsDelimiter = sqListDelimiter |
|||
) |
Implode the values in the specified list, escaping any string values that are found.
def Plugins.DataSource.SQLQueries.AnSQLQuery.prepareQueryString | ( | Self | ) |
Prepare the query string for submission to the data source.
This routine should be implemented by descendant classes. It should construct the query string from the query attributes so that the query can be successfully submitted to the data source.
def Plugins.DataSource.SQLQueries.AnSQLQuery.processCriterionPlaceholder | ( | Self, | |
value, | |||
posValues, | |||
keyValues | |||
) |
Process a placeholder from a criterion format string.
Criterion format strings are simple expressions of the form: identifier OPERATOR identifier
. The identifier
elements should be specified by placeholder values in the format string. This function will replace those placeholders with the values from the positional arguments supplied to it.
def Plugins.DataSource.SQLQueries.AnSQLQuery.processFormatValue | ( | Self, | |
value, | |||
posValues, | |||
kwValues | |||
) |
Process a value contained within a format string.
The method serves a callback for String.format(); it attempts to harden a given format string against SQL injection attacks by escaping string values passed to it. All values passed to it are converted to strings, but only values that were originally strings are escaped.
def Plugins.DataSource.SQLQueries.AnSQLQuery.queryString | ( | Self | ) |
Return the string used by the query.
def Plugins.DataSource.SQLQueries.AnSQLQuery.quoteIdentifier | ( | Self, | |
thisIdentifier | |||
) |
Return the specified identifier, delimited with the special quotes used by the data source for identifiers.
If the data source for which the query is meant to be use does not use special quote characters, this routine should simply return the identifier string, unchanged.
def Plugins.DataSource.SQLQueries.AnSQLQuery.quoteString | ( | Self, | |
thisString | |||
) |
Return the quoted form of the specified string, such that it is suitable for use with an SQL query.
This routine calls String.quote() using #sqQuoteCharacter.
def Plugins.DataSource.SQLQueries.AnSQLQuery.toString | ( | Self | ) |
Construct a string representation of the data source.
This representation will be the query string that is used by the query, if that is available, or the display name of the query class otherwise.