Skip to content
Discussion options

You must be logged in to vote

Since files are not handled the same way as python modules and packages (via the python path), you probably need to figure out the full path of the file you want to open.

How about this?

A component, containing a python module and the sql files. The other components can access the contents of the sql file via the python module:

# this is the "sql" component.
import pathlib

def open_sql_file(name: str) -> str:
    current_folder = pathlib.Path(__file__).parent

    # assuming the sql files are in the same folder in this example
    with open(f"{current_folder}/{name}") as f:
        return f.read()

Any other component or base could import the component and

# in this example, the component…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidVujic
Comment options

You must be logged in to vote
4 replies
@DavidVujic
Comment options

@elisevansbbfc
Comment options

@DavidVujic
Comment options

@DavidVujic
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants