@heyhru/server-util-mysql
v0.1.2
Published
MySQL connection pool with unified execute interface
Readme
@heyhru/server-util-mysql
MySQL connection pool with unified DbPool interface.
Install
pnpm add @heyhru/server-util-mysqlAPI
createPool(config): DbPool
Create a MySQL connection pool.
import { createPool } from "@heyhru/server-util-mysql";
const pool = createPool({
host: "localhost",
port: 3306,
database: "mydb",
username: "root",
password: "password",
poolMax: 10,
});
const rows = await pool.execute("SELECT * FROM users");
await pool.end();DbPool interface
interface DbPool {
execute(sql: string): Promise<unknown[]>;
end(): Promise<void>;
}