mehedi
mehedi
CDCloudflare Developers
Created by Alex on 4/14/2025 in #hyperdrive
Screenshot 2025-04-14 at 03.56.10
Thank you very much for the help
53 replies
CDCloudflare Developers
Created by Alex on 4/14/2025 in #hyperdrive
Screenshot 2025-04-14 at 03.56.10
Dont we have to close the connection on every request like the doc suggests?
53 replies
CDCloudflare Developers
Created by Alex on 4/14/2025 in #hyperdrive
Screenshot 2025-04-14 at 03.56.10
Hey @Alex , sorry to bother you! I'm using Drizzle with Hono, MySQL, and Hyperdrive. Could you help me confirm if my setup looks right? I'm running into similar issues too. Thanks in advance. This is the code
import { Hono } from "hono";
import { qfykActionschedulerActions } from "./db/schema";
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";

async function getDb(hyperdrive: Hyperdrive) {
const connection = await mysql.createConnection({
host: hyperdrive.host,
user: hyperdrive.user,
password: hyperdrive.password,
database: hyperdrive.database,
port: hyperdrive.port,
disableEval: true,
});
return drizzle(connection);
}

type Bindings = {
HYPERDRIVE: Hyperdrive;
};
const app = new Hono<{ Bindings: Bindings }>();

app.get("/", async (c) => {
const db = await getDb(c.env.HYPERDRIVE);
const result = await db.select().from(qfykActionschedulerActions);

return c.json({
result,
});
});

export default app;
import { Hono } from "hono";
import { qfykActionschedulerActions } from "./db/schema";
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";

async function getDb(hyperdrive: Hyperdrive) {
const connection = await mysql.createConnection({
host: hyperdrive.host,
user: hyperdrive.user,
password: hyperdrive.password,
database: hyperdrive.database,
port: hyperdrive.port,
disableEval: true,
});
return drizzle(connection);
}

type Bindings = {
HYPERDRIVE: Hyperdrive;
};
const app = new Hono<{ Bindings: Bindings }>();

app.get("/", async (c) => {
const db = await getDb(c.env.HYPERDRIVE);
const result = await db.select().from(qfykActionschedulerActions);

return c.json({
result,
});
});

export default app;
53 replies