Local Database Connection
2 minute read
When running Lapis locally, you can access its database by it using the information from your Lapis .env
file.
In this example we are using DBeaver to connect to the database.
Connecting to the database using DBeaver
Before trying to connect to your database, ensure your local Lapis is running (docker compose up local
)
-
Select
New Database Connection
which is located in the top left corner belowFile
-
Select PostgreSQL, then click
Next
-
Fill out the Connection Settings using the related keys from your Lapis
.env
file- Host: localhost
- Port:
DB_PORT
- Database:
DB_DATABASE
- Username:
DB_USERNAME
- Password:
DB_PASSWORD
-
Click
Test Connection...
, and if it succeeds clickFinish
Connecting to the database using VSCode
As above, ensure your lapis container is running before trying to connect to the database.
-
Install the VSCode PostgreSQL Extension if you do not already have it installed
-
Click the postgresql explorer icon in the sidebar
-
Click the
+
(add connection) button -
Configure the connection:
- Enter
localhost
as the address - Enter the
DB_USERNAME
from.env
- Enter the
DB_PASSWORD
from.env
- Leave the port set to
5432
- Choose
Standard Connection
- Select
All Databases
- Give your connection a name (for example,
local lapis
)
- Enter
You’re done! Now you can browse the database connection directly from VSCode. Just click the elephant icon, then expand the connection you made earlier.
To run queries on tables, you can either open the command palette and type New Query
or right click on a table and run a custom query or one of the prebaked queries.