This guide will help you set up a Neo4j database using the Neo4j Desktop application, connect it with the cardano-db-sync database, and integrate both with a Python application/back-fill script.
- Neo4j Desktop application
- Cardano DB Sync PostgreSQL database
- Python 3.12
- Pip
- Download the Neo4j Desktop application from the official website.
- Install the application following the instructions for your operating system.
- Open Neo4j Desktop.
- Click on "New" under the "Local DBMS" section.
- Give your database a name and set a password (remember this password for later).
- Click "Create" to initialize the database.
- Once created, start the database by clicking "Open".
Ensure your Neo4j database is running and note down the connection details:
- URI:
bolt://localhost:7687
- Username:
neo4j
- Password:
<your_password>
(the password you set during database creation)
- Follow the instructions found here.
Ensure your cardano-db-sync-postgres
instance is running, and note down the connection details:
- Database Name:
cexplorer
- User:
postgres
- Password: See
cardano-db-sync/config/secrets/postgres_password
file. - Host:
localhost
- Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate
- Install required Python packages:
pip install -r requirements.txt
Create a .env
file in the root directory of the project and add the following environment variables:
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=<your_password>
POSTGRES_DB=cexplorer
POSTGRES_USER=postgres
POSTGRES_PASSWORD=<your_password>
POSTGRES_HOST=localhost
- Ensure both Neo4j and Postgres databases are running.
- Run your Python application. If you want to build the graph, you can use the following command:
python extract_transactions_to_graph_store.py
You may also configure the timerange for which you want to extract transactions by modifying the start_time
and end_time
variables in the script.
- Neo4j Cypher Query Language
- PostgreSQL Documentation
- Neo4j Python Driver Documentation
- Psycopg2 Documentation
- Ensure the Neo4j and PostgreSQL services are running and accessible.
- Verify the connection details (URI, username, password, host) are correct.
- Check for any firewall or network issues that might be blocking the connections.
If you encounter any issues, refer to the respective documentation or seek help from the community forums.