21 lines
591 B
TypeScript
21 lines
591 B
TypeScript
/*
|
|
* @Date: 2025-06-12 16:48:44
|
|
* @LastEditors: 陈子健
|
|
* @LastEditTime: 2025-06-12 17:31:37
|
|
* @FilePath: /my-score/honoback/db/index.ts
|
|
*/
|
|
import { DatabaseSync } from "node:sqlite"
|
|
import { join, dirname } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
// 初始化数据库连接
|
|
const db = new DatabaseSync(join(__dirname, 'media.db'))
|
|
|
|
// 执行schema.sql中的SQL语句
|
|
const schema = readFileSync(join(__dirname, 'schema.sql'), 'utf-8')
|
|
db.exec(schema)
|
|
|
|
export { db } |