예제 #1
0
def _bind_parameters_dict(operation, parameters):

    # replace named parameters by their pyformat equivalents
    operation = re.sub(":([^\d\W]\w*)", "%(\g<1>)s", operation)

    operations = []
    for parameter in parameters:
        string_parameters = {}
        for (name, value) in six.iteritems(parameter):
            if value is None:
                string_parameters[name] = 'NULL'
            elif isinstance(value, six.string_types):
                string_parameters[name] = "'" + _escape(value) + "'"
            elif isinstance(value, datetime.date):
                string_parameters[name] = "'{0}'".format(value)
            else:
                string_parameters[name] = str(value)

        # replace pyformat parameters
        operations.append(operation % string_parameters)

    if len(operations) == 1:
        return operations[0]
    else:
        return re.sub(",INSERT INTO TABLE[^\(]+", ",", ','.join(operations))
예제 #2
0
def _bind_parameters(operation, parameters):
    # inspired by MySQL Python Connector (conversion.py)
    string_parameters = {}
    for (name, value) in parameters.iteritems():
        if value is None:
            string_parameters[name] = 'NULL'
        elif isinstance(value, basestring):
            string_parameters[name] = "'" + _escape(value) + "'"
        else:
            string_parameters[name] = str(value)
    return operation % string_parameters
예제 #3
0
def _bind_parameters(operation, parameters):
    # inspired by MySQL Python Connector (conversion.py)
    string_parameters = {}
    for (name, value) in parameters.iteritems():
        if value is None:
            string_parameters[name] = 'NULL'
        elif isinstance(value, basestring):
            string_parameters[name] = "'" + _escape(value) + "'"
        else:
            string_parameters[name] = str(value)
    return operation % string_parameters
예제 #4
0
파일: interface.py 프로젝트: cgc17/impyla
def _bind_parameters_list(operation, parameters):
    string_parameters = []
    for value in parameters:
        if value is None:
            string_parameters.append('NULL')
        elif isinstance(value, basestring):
            string_parameters.append("'" + _escape(value) + "'")
        else:
            string_parameters.append(str(value))

    # replace qmark and numeric parameters
    return _replace_numeric_markers(operation, string_parameters)
예제 #5
0
def _bind_parameters_list(operation, parameters):
    string_parameters = []
    for value in parameters:
        if value is None:
            string_parameters.append('NULL')
        elif isinstance(value, six.string_types):
            string_parameters.append("'" + _escape(value) + "'")
        else:
            string_parameters.append(str(value))

    # replace qmark and numeric parameters
    return _replace_numeric_markers(operation, string_parameters)
예제 #6
0
파일: interface.py 프로젝트: cgc17/impyla
def _bind_parameters_dict(operation, parameters):
    string_parameters = {}
    for (name, value) in parameters.iteritems():
        if value is None:
            string_parameters[name] = 'NULL'
        elif isinstance(value, basestring):
            string_parameters[name] = "'" + _escape(value) + "'"
        else:
            string_parameters[name] = str(value)

    # replace named parameters by their pyformat equivalents
    operation = re.sub(":([^\d\W]\w*)", "%(\g<1>)s", operation)

    # replace pyformat parameters
    return operation % string_parameters
예제 #7
0
def _bind_parameters_dict(operation, parameters):
    string_parameters = {}
    for (name, value) in six.iteritems(parameters):
        if value is None:
            string_parameters[name] = 'NULL'
        elif isinstance(value, six.string_types):
            string_parameters[name] = "'" + _escape(value) + "'"
        else:
            string_parameters[name] = str(value)

    # replace named parameters by their pyformat equivalents
    operation = re.sub(":([^\d\W]\w*)", "%(\g<1>)s", operation)

    # replace pyformat parameters
    return operation % string_parameters