Skip to content

Commit

Permalink
vanna-ai#548: Added additional sqlite args.
Browse files Browse the repository at this point in the history
  • Loading branch information
pygeek committed Jul 11, 2024
1 parent 1670ff7 commit 36ddc23
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/vanna/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,13 @@ def run_sql_snowflake(sql: str) -> pd.DataFrame:
self.run_sql = run_sql_snowflake
self.run_sql_is_set = True

def connect_to_sqlite(self, url: str):
def connect_to_sqlite(self, url: str, connect_same_thread: bool = False, **kwargs):
"""
Connect to a SQLite database. This is just a helper function to set [`vn.run_sql`][vanna.base.base.VannaBase.run_sql]
Args:
url (str): The URL of the database to connect to.
connect_same_thread (str): Allow the connection may be accessed in multiple threads.
Returns:
None
"""
Expand All @@ -817,7 +817,11 @@ def connect_to_sqlite(self, url: str):
url = path

# Connect to the database
conn = sqlite3.connect(url, check_same_thread=False)
conn = sqlite3.connect(
url,
check_same_thread=connect_same_tread,
**kwargs
)

def run_sql_sqlite(sql: str):
return pd.read_sql_query(sql, conn)
Expand Down

0 comments on commit 36ddc23

Please sign in to comment.