Using PostgreSQL
Using PostgreSQL with Dappetizer is really straightforward and can be set up in a few minutes.
Prerequisites
You will need the following for this guide:
For the purposes of this guide, we will assume you already have an existing Dappetizer project. Check out our Quick Start guide to learn how to set up one.
Docker (if you are planning on running PostgreSQL in Docker) or a full PostgreSQL instance
Setting up a local database
If you don't have a local PostgreSQL instance running, you can start one using Docker:
Installing PostgreSQL package
The PostgreSQL client package is required when connecting to the database. To install it, run
Configuring Dappetizer
The configuration should be changed with specific settings for connecting to PostgreSQL. To connect to your local instance, you can replace the existing database
section with:
Notice that the username and password here are stored in plaintext. That is fine for local development, but when running Dappetizer on a server, you should use a local configuration file stored on the server (the file should not be in source control) or make use of environment variables. For example, this is how you can use environment variables:
Checking the generated data
You can use any tool (like pgAdmin) to connect to the database. In this guide we will simply use Docker to run psql:
To select what blocks have been saved by the indexer, we will run a short SELECT query:
If the indexer has successfully connected to the database and started indexing, you should be able to see the stored blocks so far.
Last updated