Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
沈秋雨
/
lyric_rhyme
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
39b86113
...
39b8611312dd6d66687a4bca59e4f26e3acfa474
authored
2026-06-27 10:33:52 +0800
by
沈秋雨
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更新导出csv进度显示
1 parent
63589d3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
records.csv
scripts/download_from_db.py
records.csv
0 → 100644
View file @
39b8611
This diff could not be displayed because it is too large.
scripts/download_from_db.py
View file @
39b8611
...
...
@@ -103,8 +103,37 @@ def _encode_url(url: str) -> str:
return
urllib
.
parse
.
urlunsplit
(
parsed
.
_replace
(
path
=
encoded_path
))
def
_query_with_spinner
(
fn
,
*
args
,
**
kwargs
):
"""在后台线程执行 fn,主线程每秒打印一次进度点,完成后换行。"""
import
sys
result_box
:
list
=
[]
exc_box
:
list
=
[]
def
_run
():
try
:
result_box
.
append
(
fn
(
*
args
,
**
kwargs
))
except
Exception
as
e
:
exc_box
.
append
(
e
)
t
=
threading
.
Thread
(
target
=
_run
,
daemon
=
True
)
t
.
start
()
spinner
=
[
"⠋"
,
"⠙"
,
"⠹"
,
"⠸"
,
"⠼"
,
"⠴"
,
"⠦"
,
"⠧"
,
"⠇"
,
"⠏"
]
i
=
0
while
t
.
is_alive
():
sys
.
stderr
.
write
(
f
"
\r
{spinner[i
%
len(spinner)]} 查询中..."
)
sys
.
stderr
.
flush
()
t
.
join
(
timeout
=
0.1
)
i
+=
1
sys
.
stderr
.
write
(
"
\r
查询完成。
\n
"
)
sys
.
stderr
.
flush
()
if
exc_box
:
raise
exc_box
[
0
]
return
result_box
[
0
]
def
fetch_records
(
conn
:
psycopg
.
Connection
,
conn
,
song_ids
:
list
[
int
]
|
None
,
extra_versions
:
int
,
song_limit
:
int
,
...
...
@@ -279,7 +308,9 @@ def main() -> None:
logger
.
error
(
"缺少 psycopg,请执行: pip install psycopg"
)
raise
SystemExit
(
1
)
with
psycopg
.
connect
(
args
.
dsn
)
as
conn
:
records
=
fetch_records
(
logger
.
info
(
"查询记录中(数据量较大,请稍候)..."
)
records
=
_query_with_spinner
(
fetch_records
,
conn
,
song_ids
=
song_ids
,
extra_versions
=
args
.
extra_versions
,
...
...
Please
register
or
sign in
to post a comment