專題需要連SQL資料庫
目前查到這個專案
https://reurl.cc/eXlgEM
In the Connector's connect method below, input your connection string as the
first positional argument and the name of the database driver for the second
positional argument.
不過不太懂這段要輸入什麼以及輸入的位置
他的程式碼長這樣:
from google.cloud.sql.connector import Connector
import sqlalchemy
# initialize Connector object
connector = Connector()
# function to return the database connection
def getconn() -> pymysql.connections.Connection:
conn: pymysql.connections.Connection = connector.connect(
"project:region:instance",
"pymysql",
user="my-user",
password="my-password",
db="my-db-name"
)
return conn
# create connection pool
pool = sqlalchemy.create_engine(
"mysql+pymysql://",
creator=getconn,
)
有大師能幫忙解惑嗎?感謝QQ