Skip to content
This repository was archived by the owner on Mar 22, 2026. It is now read-only.
This repository was archived by the owner on Mar 22, 2026. It is now read-only.

Error in Reading External .SQL File #97

@matthewfarant

Description

@matthewfarant

Hello there,

I wanted to do a data transformation in SQL using pandasql and store the query result to df_final. This is the code I used:

sqlkey = lambda q : sqldf(q,globals())
query = open('query.sql', 'r')
df_final = sqlkey(query)

And query.sql is an external .SQL file located in the same directory as my notebook. I thought the code above will run the external SQL file and store the result in df_final, but instead I got an error that said:
TypeError: expected string or bytes-like object

How should I solve this issue? Thanks in advance!

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