sqlalchemy将blob转换为str python

时间:2019-05-13 06:27:50

标签: python sqlalchemy

        result = session.query(
            cls.port, cls.product, cls.portinfo,
            func.convert('A.poc_name using utf8').label('poc_name')

        ).join(A, cls.id == A.port_info_id).filter(
            (cls.result_id == max_result_id) & (cls.ip == ip)
        ).offset((page - 1) * page_size).limit(page_size).all()

我仅以字节为单位获取blob,但我想获取str,所以我使用convert却得到错误

Exception: (MySQLdb._exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS poc_name \nFROM B INNER JOIN A ON r' at line 1")
[SQL: SELECT B.port AS B_port, B.product AS B_product, B.portinfo AS B_portinfo, convert(%s) AS poc_name 
FROM B INNER JOIN A ON B.id = A.port_info_id 
WHERE B.result_id = %s AND B.ip = %s 
 LIMIT %s, %s]
[parameters: ('A.poc_name using utf8', 50, 175505510, 0, 20)]

0 个答案:

没有答案