Neon Postgres
A guide to integrate Neon resources in genezio projects
Introduction to Neon
Neon is a fully managed serverless Postgres provider. Neon separates storage and compute and offers modern developer features such as serverless, branching, bottomless storage, and more.
Set up a Neon Postgres Database
Navigate to the project integration page in the dashboard and select to Install
a Neon Postgres database to your project:
Connect with an Neon account using the preferred login method:
Create a Neon project or select an already existing project:
Select the branch, database and role for the Neon project:
Hit Save
to save the database credentials as backend environment variables
Use the environment variables in your genezio project to connect to the Postgres database.
import { Pool } from "pg";
const pool = new Pool({
connectionString: process.env.NEON_DATABASE_URL,
});
pool.query("SELECT * FROM your_table_name", (error, results) => {
console.log("Query Result:", results.rows);
pool.end();
});
Note: Install pg
using npm, if you don't have this dependency already in your project:
npm install pg
Test Locally with a Neon Postgres Database
To test your project locally, you have to create a file named .env
and store the Neon Postgres credentials there. This file should be in the root directory of your backend.
Use the genezio dashboard under Integrations/Neon Postgres
card to copy the Postgres credentials in your .env
file.
NEON_POSTGRES_URL=postgres://<username>:<password>@<hostname>/<database>
Now you can use genezio local
to start a server locally that will also load up the necessary environment variables to connect to the Postgres database.