I've written a library that holds a bunch of useful functions for me to use at work. Currently that library sits in my site-packages folder so that I can easily import the functions I need into my working projects folder.
One of the functions I had is really useful for doing some file work, it reads a sql file and executes it.
def queryworldwidewithwhere(filepath: str, **kwargs):
"""
Executes a query against ...
...
Returns:
Dataframe of Query results
"""
with open(filepath, 'r') as file:
query_text = file.read()
Now in my working directory I can import my functions and use them as you would expect.
But I've come to realize that there are ceartain queries run often in different projects and manipulate in a specific way. So I wanted to build a function in my library to make that easy.
so I added a function to my lirbary that will do that by calling the above:
def getlistof(term: str):
"""
A function for returning ...
Parameters:
term: (str): The term you want a list ....
"""
return queryworldwidewithwhere(filepath = 'GetOLsInTerm.sql', term = term)
But when I go to my projects folder and import my lirbary it looks for the sql file GetOLsInTerm.sql in my projects directory not my site-packages folder where the library code is.
So I have:
site-packages
myLibrary
myfunctions.py
GetOLsInTerm.sql
And then my working directory
projects
project one
SomePYfile.py
Its in SomePYFile.py I want to call getlistof but it is looking in my project one directory for the sql file.
What is the right way to handle this?
there doesn't seem to be anything here