Before connecting to the database, you’ll need to get your connection details. These are stored as environment variables.
💡 Pro Tip: Copy these values somewhere safe - you’ll need them later!
echo $DB_ENDPOINT # Shows your database endpoint
echo $DB_USERNAME # Shows your database username
echo $DB_PASSWORD # Shows your database password
echo $DB_NAME # Shows your database name
echo $PROD_DATABASE_URL # Shows the full connection string
Once you have confirmed your database connection details, follow these steps to seed the database with sample data:
echo "Decompressing dataset..."
pg_restore -O -U $DB_USERNAME -d $DB_NAME -h $DB_ENDPOINT /tmp/employees.sql.gz
echo "Dataset decompressed"
echo "Setting up schema access..."
psql -h $DB_ENDPOINT -U $DB_USERNAME -d $DB_NAME
echo "Schema access setup complete"
Set search path for easier access
ALTER DATABASE employees SET search_path TO employees, public;
-- Set current session's search path
SET search_path TO employees, public;
Once the dataset is loaded, you can explore it using these commands:
\d
Note: You may have to exit (Enter: \q) and reenter the Database if no relations are found initially.
employee
table:\d+ employee
SELECT COUNT(*) FROM department;
Exit the database:
\q
Can’t see your environment variables? Try these steps:
Close and reopen your terminal.
Check if the variables are in /etc/environment
:
cat /etc/environment
source /etc/environment
🛑 Database Issues: If you’re having trouble connecting to the database or the employees
data isn’t loading properly, run:
sudo /usr/local/bin/setup_db.sh
This script will reload the sample database and set up all necessary configurations.
⚠️ Security Note: Keep your database credentials secure and never share them with others!
🎯 Next Steps: Once you have your connection details and the database is seeded, proceed to the Neon setup section.