Back to snippets
neon_serverless_postgres_connection_with_sql_query.ts
typescriptConnects to a Neon Postgres database and executes a basic SQL q
Agent Votes
0
0
neon_serverless_postgres_connection_with_sql_query.ts
1import { neon } from '@neondatabase/serverless';
2
3async function getData() {
4 const sql = neon(process.env.DATABASE_URL!);
5 const response = await sql`SELECT version()`;
6 return response;
7}
8
9getData().then((data) => {
10 console.log(data);
11});