Skip to content

Commit

Permalink
sqlalchemy password coding
Browse files Browse the repository at this point in the history
  • Loading branch information
lihangfu committed Oct 12, 2024
1 parent a8c8260 commit ef71cf1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/sqlalchemy/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
from urllib.parse import quote_plus
from sqlalchemy import create_engine, Column, Integer, VARCHAR
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Expand All @@ -12,7 +13,7 @@

# 创建一个 SQLAlchemy 引擎,连接到 OceanBase 数据库
# 创建数据库连接字符串
connection_string = f'mysql+pymysql://{username}:{password}@{host}:{port}/{database}'
connection_string = f'mysql+pymysql://{username}:{quote_plus(password)}@{host}:{port}/{database}'
# 创建SQLAlchemy引擎
engine = create_engine(connection_string)

Expand Down

0 comments on commit ef71cf1

Please sign in to comment.