yum.sqlutils

utility functions to handle differences in pysqlite versions These are from Wichert Akkerman <wichert@deephackmode.org>’s python-dhm http://www.wiggy.net/code/python-dhm

TokenizeError

class yum.sqlutils.TokenizeError

Bases: exceptions.Exception

Tokenizer error class

yum.sqlutils.Tokenize(str, whitespace=' \t\r\n', quotes='"', escapes='\\')

String tokenizer

This function tokenizes a string while taking quotation and escaping into account.

>>> import dhm.strtools
>>> dhm.strtools.Tokenize("this is a test")
['this', 'is', 'a', 'test']
>>> dhm.strtools.Tokenize("this "is a" test")
['this', 'is a', 'test']
>>> dhm.strtools.Tokenize("this \"is\" a test")
['this', '"is"', 'a', 'test']
>>> dhm.strtools.Tokenize("this "is a test")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.2/site-packages/dhm/strtools.py", line 80, in Tokenize
    raise TokenizeError, "Unexpected end of string in quoted text"
dhm.strtools.TokenizeError: Unexecpted end of string in quoted text

@param str: string to tokenize @type str: string @param whitespace: whitespace characters seperating tokens @type whitespace: string @param quotes: legal quoting characters @type quotes: string @param escapes: characters which can escape quoting characters @type escapes: string @return: list of tokens @rtype: sequence of strings

yum.sqlutils.QmarkToPyformat(query, params)

Convert from qmark to pyformat parameter style.

The python DB-API 2.0 specifies four different possible parameter styles that can be used by drivers. This function converts from the qmark style to pyformat style.

@param query: SQL query to transform @type query: string @param params: arguments to query @type params: sequence of strings @return: converted query and parameters @rtype: tuple with the new command and a dictionary of arguments

yum.sqlutils.executeSQLPyFormat(cursor, query, params=None)

Execute a python < 2.5 (external sqlite module) style query.

@param cursor: A sqlite cursor @param query: The query to execute @param params: An optional list of parameters to the query

yum.sqlutils.executeSQLQmark(cursor, query, params=None)

Execute a python 2.5 (sqlite3) style query.

@param cursor: A sqlite cursor @param query: The query to execute @param params: An optional list of parameters to the query

yum.sqlutils.sql_esc(pattern)

Apply SQLite escaping, if needed. Returns pattern and esc.

yum.sqlutils.sql_esc_glob(patterns)

Converts patterns to SQL LIKE format, if required (or gives up if not possible).

Table Of Contents

Previous topic

yum.sqlitesack

Next topic

yum.transactioninfo

This Page