Skip to content

Commit

Permalink
rm author and port
Browse files Browse the repository at this point in the history
  • Loading branch information
521xueweihan committed May 29, 2024
1 parent 9c61504 commit a448a8b
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 14 deletions.
3 changes: 1 addition & 2 deletions python/sqlalchemy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ obd demo
username = 'root' # 「账号管理」页面创建的账号
password = '' # 「账号管理」页面创建的账号密码
host = 'localhost' # 「数据库实例」页面开通的公网地址
port = '3306' # 无需改动
port = '2881' # OceanBase 端口号
database = 'test' # 「数据库管理」页面创建的数据库
```

修改代码中的连接信息,在命令行进入到 `python/sqlalchemy` 目录,直接执行 `python example.py` 运行示例代码,输出结果如下:

```
<User(name=HelloGitHub, age=9)>
<User(name=Alice, age=30)>
<User(name=Bob, age=25)>
<User(name=Alice, age=30)>
Expand Down
2 changes: 0 additions & 2 deletions python/sqlalchemy/demo/db/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2024-05-29 14:28
# Desc : SQLAlchemy 引擎和 OceanBase 基表定义
from contextlib import contextmanager
Expand Down
4 changes: 1 addition & 3 deletions python/sqlalchemy/demo/db/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2024-05-29 14:28
# Desc : 配置文件

Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions python/sqlalchemy/demo/db/curd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2024-05-29 14:28
# Desc : 操作表的数据
from sqlalchemy.orm import Session
Expand Down
2 changes: 0 additions & 2 deletions python/sqlalchemy/demo/db/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2024-05-29 14:28
# Desc : 配置文件
from sqlalchemy import Column, Integer, VARCHAR
Expand Down
2 changes: 0 additions & 2 deletions python/sqlalchemy/demo/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2024-05-29 14:28
# Desc : 运行入口
from db.base import get_db
Expand Down
2 changes: 1 addition & 1 deletion python/sqlalchemy/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
username = 'root'
password = ''
host = 'localhost'
port = '3306'
port = '2881'
database = 'test'

# 创建一个 SQLAlchemy 引擎,连接到 OceanBase 数据库
Expand Down

0 comments on commit a448a8b

Please sign in to comment.