Skip to content

Commit cd47ac6

Browse files
committed
perf(sqlite): 增加数据库异常捕获
1 parent c705b02 commit cd47ac6

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,8 @@ A: 由于权限限制,您无法直接触发主仓库的 Actions。请通过 Fo
395395

396396
## TikHub
397397

398-
<p><a href="https://tikhub.io/">TikHub</a> 是一家领先的数据接口服务供应商,专注于提供高质量的数据接口,涵盖了多个热门平台,包括 抖音、TikTok、小红书、Instagram、Twitter 和 快手 等平台。</p>
399-
<p>TikHub 还提供定制化的服务,如直播间监控、作品监控和达人监控,以满足不同业务场景的需求。</p>
400-
<p>通过每日签到,用户可以免费获取一定额度的使用量;可以使用我的 <strong>推荐链接</strong>:<a href="https://user.tikhub.io/users/signup?referral_code=ZrdH8McC">https://user.tikhub.io/users/signup?referral_code=ZrdH8McC</a> 或 <strong>推荐码</strong>:<code>ZrdH8McC</code>,注册并充值即可获得 <code>$2</code> 额度!</p>
398+
<p><a href="https://tikhub.io/">TikHub</a>:第三方 API 服务供应商,专注于提供各平台 API。</p>
399+
<p>通过每日签到,用户可以免费获取少量使用额度;可以使用我的 <strong>推荐链接</strong>:<a href="https://user.tikhub.io/users/signup?referral_code=ZrdH8McC">https://user.tikhub.io/users/signup?referral_code=ZrdH8McC</a> 或 <strong>推荐码</strong>:<code>ZrdH8McC</code>,注册并充值即可获得 <code>$2</code> 额度!</p>
401400

402401
# 💡 项目参考
403402

README_EN.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,8 @@ repository to execute the build process
405405

406406
## TikHub
407407

408-
<p><a href="https://tikhub.io/">TikHub</a> is a leading data interface service provider, specializing in offering high-quality data interfaces for multiple popular platforms, including DouYin, TikTok, Xiaohongshu, Instagram, Twitter, and Kuaishou.</p>
409-
<p>TikHub also provides customized services such as live streaming room monitoring, post monitoring, and influencer monitoring to meet the needs of different business scenarios.</p>
410-
<p>Through daily sign-ins, users can obtain a certain quota of usage for free. You can use my <strong>referral link</strong>:<a href="https://user.tikhub.io/users/signup?referral_code=ZrdH8McC">https://user.tikhub.io/users/signup?referral_code=ZrdH8McC</a> or <strong>Referral Code</strong>:<code>ZrdH8McC</code>,Register and recharge to receive <code>$2</code> limit!</p>
408+
<p><a href="https://tikhub.io/">TikHub</a>: Third-party API provider offering multi-platform APIs.</p>
409+
<p>Through daily check-ins, users can earn a small amount of free usage credits. You can also use my <strong>referral link</strong>: <a href="https://user.tikhub.io/users/signup?referral_code=ZrdH8McC">https://user.tikhub.io/users/signup?referral_code=ZrdH8McC</a> or <strong>referral code</strong>: <code>ZrdH8McC</code>, register and top up to get a $2 credit!</p>
411410

412411
# 💡 Project References
413412

src/storage/sqlite.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
from re import sub
33

44
from aiosqlite import connect
5+
from sqlite3 import OperationalError
56

7+
from rich.text import Text
8+
from rich import print
9+
10+
from custom import ERROR
11+
from ..translation import _
612
from .sql import BaseSQLLogger
713

814
__all__ = ["SQLLogger"]
@@ -66,7 +72,26 @@ async def update_sheet(self):
6672
mark[-1] = old_sheet
6773
old_sheet = "_".join(mark)
6874
if await self.__check_sheet_exists(old_sheet):
69-
await self.cursor.execute(self.UPDATE_SQL, (old_sheet, new_sheet))
75+
try:
76+
await self.cursor.execute(self.UPDATE_SQL, (old_sheet, new_sheet))
77+
except OperationalError as e:
78+
print(
79+
Text(
80+
" ".join(
81+
(
82+
_(
83+
"更新数据表名称时发生错误,重命名失败,请向作者反馈以便修复问题!"
84+
),
85+
e,
86+
old_sheet,
87+
new_sheet,
88+
)
89+
),
90+
style=ERROR,
91+
)
92+
)
93+
self.name = old_sheet
94+
return
7095
await self.db.commit()
7196
self.name = new_sheet
7297

0 commit comments

Comments
 (0)