The types there are fairly stable (beta notwithstanding; always risk of some changes)
The types there are fairly stable (beta notwithstanding; always risk of some changes)
pg@8.11.0, initiating kysely like this:LOCAL_DATABASE_URL for local development (connectionstring including ?sslmode=require), I'm able to setup the connection, but any query will yield Error: Connection terminated unexpectedly. localConnectionString instead of bypassing hyperdrive in local dev, but it transforms my connectionstring to some hyperdrive.local url.?sslmode=require in my connection stringNODE_EXTRA_CA_CERTS=./assets/certificate.pem wrangler dev solved the issue.


pg@8.11.0const connectionString =
env.LOCAL_DATABASE_URL || env.HYPERDRIVE.connectionString;
new Kysely<DB>({
dialect: new PostgresDialect({
pool: new Pool({
max: 1,
connectionString,
ssl: {
rejectUnauthorized: false,
},
}),
}),
});LOCAL_DATABASE_URL?sslmode=require?sslmode=requireError: Connection terminated unexpectedlylocalConnectionStringhyperdrive.local[wrangler:err] Error: internal error
at cachedError (/x/node_modules/postgres/cf/src/query.js:170:23)
at new Query (/x/node_modules/postgres/cf/src/query.js:36:24)
at sql2 (/x/node_modules/postgres/cf/src/index.js:113:11)
at Object.fetch (/x/index.ts:9:23)import postgres from 'postgres';
export default {
async fetch(request: Request, env: any) {
const connectionString =
env.DATABASE_URL || env.HYPERDRIVE.connectionString;
console.log('fetch', request.url, env.DATABASE_URL);
const sql = postgres(connectionString);
const abc = await sql`SELECT * FROM tenant LIMIT 10`;
console.log('abc', abc);
return new Response(JSON.stringify({ ok: true }));
},
};{
"name": "x",
"dependencies": {
"postgres": "^3.4.3"
}
}name = "xyz"
compatibility_flags = ["nodejs_compat"]NODE_EXTRA_CA_CERTS=./assets/certificate.pem wrangler dev