sql >> Base de Datos >  >> RDS >> PostgreSQL

python 2.7 a python 3.4 error tipo(s) de operando no admitido para %:'bytes' y 'dict'

Gracias a los comentarios, lo porté a python 3

def compile_query(query):
    dialect = query.session.bind.dialect
    statement = query.statement
    comp = compiler.SQLCompiler(dialect, statement)
    comp.compile()
    enc = dialect.encoding
    params = {}
    for k,v in comp.params.items():
        if isinstance(v, str):
            v = v.encode(enc)
        params[k] = sqlescape(v)
    return (comp.string % params)