8000 fix: use lazy refresh for Cloud SQL Connector by jackwotherspoon · Pull Request #86 · googleapis/langchain-google-cloud-sql-mysql-python · GitHub
[go: up one dir, main page]

Skip to content

fix: use lazy refresh for Cloud SQL Connector #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"langchain-community>=0.0.18, <1.0.0",
"numpy>=1.24.4, <2.0.0",
"SQLAlchemy>=2.0.7, <3.0.0",
"cloud-sql-python-connector[pymysql]>=1.7.0, <2.0.0"
"cloud-sql-python-connector[pymysql]>=1.10.0, <2.0.0"
]

classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ langchain-community==0.2.0
numpy===1.24.4; python_version <= "3.8"
numpy==1.26.4; python_version > "3.8"
SQLAlchemy==2.0.30
cloud-sql-python-connector[pymysql]==1.9.2
cloud-sql-python-connector[pymysql]==1.10.0

6 changes: 4 additions & 2 deletions src/langchain_google_cloud_sql_mysql/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import google.auth.transport.requests
import requests
import sqlalchemy
from google.cloud.sql.connector import Connector
from google.cloud.sql.connector import Connector, RefreshStrategy

from .version import __version__

Expand Down Expand Up @@ -193,7 +193,9 @@ def _create_connector_engine(
enable_iam_auth = True

if cls._connector is None:
cls._connector = Connector(user_agent=USER_AGENT)
cls._connector = Connector(
user_agent=USER_AGENT, refresh_strategy=RefreshStrategy.LAZY
)

# anonymous function to be used for SQLAlchemy 'creator' argument
def getconn() -> pymysql.Connection:
Expand Down
Loading
0