diff --git a/python/sqlalchemy/README.md b/python/sqlalchemy/README.md index 15de920..32832e2 100644 --- a/python/sqlalchemy/README.md +++ b/python/sqlalchemy/README.md @@ -59,14 +59,13 @@ obd demo username = 'root' # 「账号管理」页面创建的账号 password = '' # 「账号管理」页面创建的账号密码 host = 'localhost' # 「数据库实例」页面开通的公网地址 -port = '3306' # 无需改动 +port = '2881' # OceanBase 端口号 database = 'test' # 「数据库管理」页面创建的数据库 ``` 修改代码中的连接信息,在命令行进入到 `python/sqlalchemy` 目录,直接执行 `python example.py` 运行示例代码,输出结果如下: ``` - diff --git a/python/sqlalchemy/demo/db/base.py b/python/sqlalchemy/demo/db/base.py index 79ae567..68a6cc9 100644 --- a/python/sqlalchemy/demo/db/base.py +++ b/python/sqlalchemy/demo/db/base.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- # -# Author : XueWeiHan -# E-mail : 595666367@qq.com # Date : 2024-05-29 14:28 # Desc : SQLAlchemy 引擎和 OceanBase 基表定义 from contextlib import contextmanager diff --git a/python/sqlalchemy/demo/db/config.py b/python/sqlalchemy/demo/db/config.py index 98f069f..abb3864 100644 --- a/python/sqlalchemy/demo/db/config.py +++ b/python/sqlalchemy/demo/db/config.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- # -# Author : XueWeiHan -# E-mail : 595666367@qq.com # Date : 2024-05-29 14:28 # Desc : 配置文件 @@ -15,7 +13,7 @@ def oceanbase_db_url(): username = 'root' password = '' host = 'localhost' - port = '3306' + port = '2881' database = 'test' db_url = 'mysql+pymysql://{username}:{password}@{host}:{port}/{database}'.format( username=username, password=password, host=host, port=port, database=database) diff --git a/python/sqlalchemy/demo/db/curd.py b/python/sqlalchemy/demo/db/curd.py index 6720f52..c3260a9 100644 --- a/python/sqlalchemy/demo/db/curd.py +++ b/python/sqlalchemy/demo/db/curd.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- # -# Author : XueWeiHan -# E-mail : 595666367@qq.com # Date : 2024-05-29 14:28 # Desc : 操作表的数据 from sqlalchemy.orm import Session diff --git a/python/sqlalchemy/demo/db/models.py b/python/sqlalchemy/demo/db/models.py index de5ccf2..50eaa4b 100644 --- a/python/sqlalchemy/demo/db/models.py +++ b/python/sqlalchemy/demo/db/models.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- # -# Author : XueWeiHan -# E-mail : 595666367@qq.com # Date : 2024-05-29 14:28 # Desc : 配置文件 from sqlalchemy import Column, Integer, VARCHAR diff --git a/python/sqlalchemy/demo/main.py b/python/sqlalchemy/demo/main.py index a5633ba..6a9eb98 100644 --- a/python/sqlalchemy/demo/main.py +++ b/python/sqlalchemy/demo/main.py @@ -1,7 +1,5 @@ # -*- coding:utf-8 -*- # -# Author : XueWeiHan -# E-mail : 595666367@qq.com # Date : 2024-05-29 14:28 # Desc : 运行入口 from db.base import get_db diff --git a/python/sqlalchemy/example.py b/python/sqlalchemy/example.py index 30b1ce2..e00a632 100644 --- a/python/sqlalchemy/example.py +++ b/python/sqlalchemy/example.py @@ -7,7 +7,7 @@ username = 'root' password = '' host = 'localhost' -port = '3306' +port = '2881' database = 'test' # 创建一个 SQLAlchemy 引擎,连接到 OceanBase 数据库