new to functions so obviously there are lack of knowledge around the basics of this. I want to create a function which fetch data from sql server but I don't know how to pass it to a dataframe. This dataframe will later be used by other functions This what I have done so far.
class Inputdata:
def __init__():
driver_path = ("Driver={SQL Server};"
"Server=xxx;"
"Database=xxx;"
"Trusted_Connection=xxx;")
def select(self, query, con):
con = pyodbc.connect(driver_path)
query = """ Select * FROM TABLE """
result = pd.read_sql(query,con)
return result
Try this, but adopt to your needs please.