Browse Source

更新代办事项

qyl 1 year ago
parent
commit
2b22f54bfc
4 changed files with 88 additions and 11 deletions
  1. 57 0
      db/readme.md
  2. 17 3
      db/user.py
  3. 1 1
      douyin_openapi_web.http
  4. 13 7
      待办事项.md

+ 57 - 0
db/readme.md

@@ -0,0 +1,57 @@
+# 介绍
+```shell
+dk pull citusdata/citus
+# 启动数据库。账户名 pg ,密码 pg
+docker run -d --name citus -p 5432:5432 -e POSTGRES_USER=pg -e POSTGRES_PASSWORD=pg citusdata/citus
+```
+
+## sqlmodle 操作数据库
+see python code: ./db/
+
+
+## 界面操作数据库
+- 下载并安装  https://github.com/dbeaver/dbeaver/releases/tag/23.3.3
+- 左上角小图标 “新建数据库连接”  -  PostgreSQL - 主机:sv-v.magong.site (仅支持ipv6) 端口:5432 - 数据库: douyin - 用户名: pg  - 密码: pg 
+- (可选)显示所有数据库: 上方切换标签 PostgreSQL - 显示所有数据库连接 
+- 完成
+
+## 命令行操作数据库
+```shell
+# 查看版本号
+pgcli -v
+# 如果出错,需要安装依赖工具:pip install psycopg_binary  
+# see:https://github.com/dbcli/pgcli/issues/1413
+
+# 进入数据库命令行, sv-v 是另一台内网主机的域名, 5432 端口, pg 是 PostgreSQL 用户名, douyin 是其中一个数据库
+pgcli -h sv-v -p 5432 -U pg douyin
+# 查看 pgcli 支持指令
+\?
+# 查看 SQL 指令
+\h
+# 查看当前数据库名称和用户名
+\c
+# 新建数据库
+create database douyin
+# 列出所有数据库
+\l
+# 退出命令行
+quit
+
+# 免密输入。设置环境变量
+export PGPASSWORD=pg
+# 此时访问数据库不再需要密码。 -l 是列出有多少个数据库
+pgcli -h sv-v -p 5432 -U pg -l
+```
+
+## 参考文档
+PostgreSQL 官网: https://github.com/postgres/postgres ,github 地址:https://github.com/postgres/postgres
+
+本项目使用的版本是 PostgreSQL 14.0 ,官方文档: https://www.postgresql.org/docs/14/index.html
+
+Citus 是一个 PostgreSQL 插件,主要用户扩展、管理基于 PostgreSQL 的分布式集群。
+
+Citus 官方文档: https://docs.citusdata.com/en/stable/installation/single_node_docker.html
+
+Citus 官方仓库: https://github.com/citusdata/citus?tab=readme-ov-file
+
+pgcli 是一个命令行工具,可以在Python环境中使用命令行操作 PostgreSQL 数据库。安装: `pip install pgcli`,

+ 17 - 3
db/user.py

@@ -1,12 +1,26 @@
 from typing import Optional
 
-from sqlmodel import Field, SQLModel
+from sqlmodel import Field, SQLModel,create_engine,Session
+
+
 
 # 定义数据库模型  
 class UserOAuthToken(SQLModel, table=True):  
-    id = Field(default=None, primary_key=True)
+    id: Optional[int] = Field(default=None, primary_key=True)
     access_token:str
     expires_in: Optional[int] = None
     open_id:str
     refresh_expires_in: Optional[int] = None
-    refresh_token:str
+    refresh_token:str
+
+
+test=UserOAuthToken(access_token="dfgfaha",open_id="dasfga",refresh_token="fagsdgas");
+DATABASE_URL = "postgresql:///test.db"
+engine = create_engine(DATABASE_URL)
+SQLModel.metadata.create_all(engine)
+
+
+with Session(engine) as session:
+    session.add(test)
+    session.commit()
+

+ 1 - 1
douyin_openapi_web.http

@@ -1,6 +1,6 @@
 # WEB扫码接入 参考 https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/sdk/web-app/web/permission
 # 打开链接,扫码登录 
-GET https://open.douyin.com/platform/oauth/connect/?client_key=aw6aipmfdtplwtyq&response_type=code&scope=user_info,renew_refresh_token,trial.whitelist&redirect_uri=https://open-douyin.magong.site/verify_callback HTTP/1.1  
+GET https://open.douyin.com/platform/oauth/connect/?client_key=aw6aipmfdtplwtyq&response_type=code&scope=user_info,renew_refresh_token,trial.whitelist&redirect_uri=https://open-douyin-cf.magong.site/verify_callback HTTP/1.1  
 Host: open.douyin.com
 
 # 服务器收到返回信息

+ 13 - 7
待办事项.md

@@ -1,7 +1,8 @@
 # qyl
+- [x] 试一下内网穿透、修改SSH本地配置文件、本地 proxy
 - [ ] **了解数据库**
-  - [ ] 数据库模型 sqlmodel ,官方文档: https://github.com/tiangolo/sqlmodel  
-  - [ ] 数据库软件 PostgreSQL 。 2023 最流行的开源数据库,超越 MySQL 。官网: https://github.com/postgres/postgres ,github 地址:https://github.com/postgres/postgres
+  - [x] 数据库模型 sqlmodel ,官方文档: https://github.com/tiangolo/sqlmodel  
+  - [x] 数据库软件 PostgreSQL 。 2023 最流行的开源数据库,超越 MySQL 。官网: https://github.com/postgres/postgres ,github 地址:https://github.com/postgres/postgres
   - [ ] 根据 sqlmodel 的方式编写代码,定义数据库模型,连接至 PostgreSQL ,代码存放在 db/ 目录中
 - [ ] **获取抖音用户信息**
   - [ ] 参考文档 https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/sdk/web-app/web/permission
@@ -12,12 +13,17 @@
   - [ ] 评估大模型记忆框架 MemoryBank https://zhuanlan.zhihu.com/p/674220905?utm_campaign=shareopn&utm_medium=social&utm_oi=766444166291935232&utm_psn=1730836140159057920&utm_source=wechat_session
 
 # mrh
-- [ ] **了解数据库**
-  - [ ] 数据库模型 sqlmodel ,官方文档: https://github.com/tiangolo/sqlmodel  
-  - [ ] 数据库软件 PostgreSQL 。 2023 最流行的开源数据库,超越 MySQL 。官网: https://github.com/postgres/postgres ,github 地址:https://github.com/postgres/postgres
-  - [ ] 部署数据库服务器 PostgreSQL ,确定分布式数据库可行性 https://blog.csdn.net/qq_23934063/article/details/120267886
+- [x] **了解数据库**
+  - [x] 数据库模型 sqlmodel ,官方文档: https://github.com/tiangolo/sqlmodel  
+  - [x] 数据库软件 PostgreSQL 。 2023 最流行的开源数据库,超越 MySQL 。官网: https://github.com/postgres/postgres ,github 地址:https://github.com/postgres/postgres
+  - [x] 部署数据库服务器 PostgreSQL ,确定分布式数据库可行性 https://blog.csdn.net/qq_23934063/article/details/120267886。微软Citus 11 for Postgres分布式架构 https://github.com/citusdata/citus
+  - [x] 已完成部署,[使用教程](./db/readme.md)
+- [ ] **内网穿透**
+  - 💡 必要性:一个应用程序/网站有许多微服务,子请求到不同的后端主机,负载均衡,数据库,文件服务器,对象存储,大文件、音视频流点对点传输,用户没有ipv6,方便协作开发,等等
+  - [x] 评估 FRP 穿透打洞可行性,方便API动态增删改查隧道 (不可行,打洞仍需要中继公网服务器)
+  - [ ] natter 搭建一个 API 增删改查隧道。natter + Vmess 探究
 - [ ] **编写前端代码**
-  - [ ] 扫码登录,页面跳转
+  - [ ] 扫码登录,页面跳转。前端项目:[vue-pure-admin](https://mp.weixin.qq.com/s/iJPJizHKhbXe9iHpclU3FA) 基于 Vue3、Vite、Element-Plus 和 TypeScript 编写的后台管理系统。github链接:https://github.com/xiaoxian521/vue-pure-admin
   - [ ] 了解用户鉴权, element-plus-admin + Fastapi + Oauth2
   - [ ] 从数据库获取用户数据,展示到用户登录页中
   - [ ] 文档上传、下载、更新、删除