🔮
Flair
ExamplesCLIDiscordTelegram
  • 👋Flair: Fast EVM Indexer
  • 🙋FAQ
    • How to choose an indexer?
  • 💰Pricing
  • 👩‍💻Talk to an engineer
  • reference
    • ⚙️manifest.yml
    • 🧞‍♂️Custom Scripting
      • Event Processors
    • 🚄Backfilling
    • 🔋Database
      • JDBC (MySQL, Postgres)
      • MongoDB
      • DynamoDB
    • 😎CLI Commands
    • 🌟Best Practices
  • Advanced
    • 📶Aggregations
    • 🎆Integrations
Powered by GitBook
On this page

Was this helpful?

  1. reference
  2. Database

JDBC (MySQL, Postgres)

Sync your indexed and processed entities to a JDBC-compatible database like PostgreSQL

Last updated 1 year ago

Was this helpful?

To sync your data to MySQL or Postgres using JDBC:

  1. Follow the instructions in the .

  2. Add the mysql.password (or postgres.password) secret to your cluster:

flair secret set -n mysql.password -v XXXXXXXXXXX
  1. Change the connector url depending on the DB engine, anywhere you have a "sink", i.e. in both streaming and batch .sql files:

CREATE TABLE sink_Swap (
    `entityId` STRING,
    `entityUpdatedAt` BIGINT,
    `chainId` INT,
    `contractAddress` STRING,
    `horizon` STRING,
    `blockNumber` BIGINT,
    `blockTimestamp` BIGINT,
    `forkIndex` INT,
    `transactionIndex` INT,
    `logIndex` INT,
    `localIndex` INT,
    `txHash` STRING,
    `txTo` STRING,
    `txFrom` STRING,
    `assetId` STRING,
    `resolver` STRING,
    PRIMARY KEY (`entityId`) NOT ENFORCED
) WITH (
    'connector' = 'jdbc',
    'url' = 'jdbc:mysql://DB_HOST_HERE/DB_NAME_HERE', // or 'jdbc:postgresql://DB_HOST_HERE/DB_NAME_HERE'
    'table-name' = 'my_swaps',
    'username' = 'USERNAME',
    'password' = '{{ secret("mysql.password") }}', // or {{ secret("postgres.password") }}
    'sink.max-retries' = '10',
    'sink.buffer-flush.interval' = '60s'
);

Make sure to replace HOST, DB, USERNAME, with your DB host, database name, username respectively.

🔋
main page