Skip to content

Commit

Permalink
fix: Don't throw password not found if conn string is used
Browse files Browse the repository at this point in the history
- Using no raise doesn't add err message in the message_log to begin
  with
- Use site_cache to be multi-tenant safe instead of functools.cache
  • Loading branch information
gavindsouza committed Mar 22, 2024
1 parent 85feb6a commit 4eb7884
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# For license information, please see license.txt


from contextlib import suppress
from functools import cached_property, lru_cache
from functools import cached_property

import frappe
from frappe.model.document import Document
from frappe.utils.caching import redis_cache
from frappe.utils.caching import redis_cache, site_cache

from insights import notify
from insights.api.telemetry import track
Expand Down Expand Up @@ -204,9 +203,7 @@ def _db(self) -> BaseDatabase:
if self.database_type == "SQLite":
return SQLiteDB(data_source=self.name, database_name=self.database_name)

password = None
with suppress(BaseException):
password = self.get_password()
password = self.get_password(raise_exception=False)

conn_args = {
"data_source": self.name,
Expand Down Expand Up @@ -273,7 +270,7 @@ def get_table_preview(self, table, limit=100):
return self._db.get_table_preview(table, limit)


@lru_cache(maxsize=128)
@site_cache(maxsize=128)
def get_data_source_schema(data_source):
Table = frappe.qb.DocType("Insights Table")
TableColumn = frappe.qb.DocType("Insights Table Column")
Expand Down

0 comments on commit 4eb7884

Please sign in to comment.