Skip to content

Error when recording SQL queries that are byte-strings #987

Closed
@ahardjasa

Description

@ahardjasa

When a byte-string SQL query is run, e.g. those produced by psycopg2.execute_values, I get the error TypeError: startswith first arg must be bytes or a tuple of bytes, not str.

This seems to be a result of line 142 in django-debug-toolbar/debug_toolbar/panels/sql/tracking.py: 'is_select': sql.lower().strip().startswith('select')
since 'select' is unicode.

Flask-debugtoolbar addressed this with prefix = b'select' if isinstance(statement, bytes) else 'select' - would that work in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions