Neon

Guide to connect Neon to Velvet

Connect your Neon database to your Velvet workspace. You can skip some steps if you've previously connected to other services.

1. Create a read-only user

Create a user with read-only permissions in Neon.

If you don’t already have psql installed on your machine, you’ll need to install it. This is often part of the PostgreSQL client tools.

Navigate to the database in Neon. Go to the management page and copy the string listed.

Copy the following command into your terminal psql <connection-string-copied-above>

Run the following SQL statements into the terminal which you connected to your Neon database.

-- Create a new user with read-only access to the database
-- Recommend to run each step one by one, as some steps may
-- fail if the user does not have the necessary privileges.

-- Step 1: Create the user
CREATE USER velvet_readonly WITH LOGIN PASSWORD 'your_secure_password';

-- Step 2: Grant connect privilege to the database 
-- (replace your_database_name with the actual name - on supabase it's postgres)
GRANT CONNECT ON DATABASE postgres TO velvet_readonly;

-- Step 3: Grant usage on schemas. This allows the user to see the schemas
GRANT USAGE ON SCHEMA public TO velvet_readonly;
GRANT USAGE ON SCHEMA auth TO velvet_readonly; -- optional

-- Step 4: Grant select on all tables and views in the schemas
GRANT SELECT ON ALL TABLES IN SCHEMA public TO velvet_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA auth TO velvet_readonly;

-- Step 5: Ensure future tables and views in these schemas are also accessible
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO velvet_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA auth GRANT SELECT ON TABLES TO velvet_readonly;

-- [OPTIONAL] Step 6: Bypass RLS policies
ALTER ROLE velvet_readonly BYPASSRLS;

These statements create a velvet readonly user with the password a very good password. It gives them the velvet_read_all_data role.

2. Set static IPs

Configure network restrictions to allow Velvet's static IP addresses. Follow our static IP configuration guide.

3. Build your connection string

Read our general guide on URI construction here. The Neon-specific overview is below.

Copy your Neon URI

Navigate to the database in Neon. Go to the management page and copy the string listed.

Add to the string

After the database name, add ?ssl={"require":true,"rejectUnauthorized":false,"servername":"[insert-your-neon-hostname.com](http://insert-your-neon-hostname.com/)"} to the connection string.

Your full connection string will look something like this:

postgresql://<user>:<password>@<neon-host-name>/<db-name>?ssl={"require":true,"rejectUnauthorized":false,"servername":"<[insert-your-neon-hostname.com](http://insert-your-neon-hostname.com/)>"}

Velvet IPs

Check if you have any network restrictions that require a static IP address. If so, you'll need to allowlist the Velvet IPs.

4. Connect your database

Connect your database to Velvet using your connection string.

  1. Tap into a workspace in your Velvet dashboard
  2. Tap "Add a data source"
  3. Select type "Remote database"
  4. Name your database
  5. Paste in your database URI
  6. Press create

If you run into any errors, schedule a call or email [email protected].

Once your database is connected, you're ready to use the AI SQL editor. Close out of the modal to start using the editor on top of your database.

Schema mapping is optional, and only required if you want to query multiple sources at the same time.

5. [optional] Schema mapping for unified sources

This configuration is only required to query multiple data sources at the same time. For example - two databases at the same time, or stripe webhooks alongside your database tables.

You can set up this unified mapping any time.

Add schema mapping context

After you connect your database, you'll be prompted to configure the schema for each table you set up.

Name your table to create this source.

Repeat these schema mapping steps for each table you want included as a unified data source.

Get help

Email [email protected] if you need additional support.