MCPcopy Create free account
hub / github.com/Cicada000/VV / create_subtitle_database

Function create_subtitle_database

DataProcess/create_db.py:4–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import os
3
4def create_subtitle_database():
5 # 如果数据库文件存在,先删除它
6 if os.path.exists('subtitles.db'):
7 os.remove('subtitles.db')
8 print("已删除旧的数据库文件")
9
10 conn = sqlite3.connect('subtitles.db')
11 cursor = conn.cursor()
12
13 # 创建字幕表
14 cursor.execute('''
15 CREATE TABLE IF NOT EXISTS subtitles (
16 id INTEGER PRIMARY KEY AUTOINCREMENT,
17 episode_title TEXT NOT NULL,
18 timestamp TEXT NOT NULL,
19 similarity REAL,
20 text TEXT NOT NULL
21 )
22 ''')
23
24 # 创建全文搜索索引
25 cursor.execute('''
26 CREATE VIRTUAL TABLE IF NOT EXISTS subtitles_fts USING fts5(
27 episode_title,
28 timestamp,
29 similarity,
30 text,
31 content='subtitles',
32 content_rowid='id'
33 )
34 ''')
35
36 conn.commit()
37 conn.close()
38 print("已创建新的数据库文件")

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected