unibutton/db.js

19 lines
363 B
JavaScript
Raw Normal View History

2024-10-08 20:48:38 -04:00
import sqlite3 from 'sqlite3'
import { open } from 'sqlite'
let db;
async function initDb() {
if (db) return db;
db = await open({
filename: `${process.cwd()}/db/main.db`,
driver: sqlite3.Database
});
await db.run(`CREATE TABLE IF NOT EXISTS stats (username TEXT, ip TEXT, ko TEXT);`);
return db;
}
export default initDb;