Copying a MySQL Database into PostgreSQL, and Four Checks That Prove It Arrived
We walked our MySQL setup guide end to end against a small online-store database: 50 sellers, 500 goods, 2,000 orders and 4,632 order items. The destination was PostgreSQL. One run later, the run page reported Rows 7182 . That number is the pipeline's report about itself. It is the right place to start and the wrong place to stop, because a load can finish, report a plausible total and still not…
We transferred a MySQL database containing a small online store's data to PostgreSQL. The destination database had 50 sellers, 500 goods, 2,000 orders, and 4,632 order items. After the transfer, the total number of rows reported was 7,182, which covered all the tables written by the load without including the two dlt bookkeeping tables.
The transfer used a read-only user with database-level SELECT privileges, granting access to all tables. The whole database was uploaded in one run using the full_database load mode, with table names converted to lowercase and underscores replacing whitespace. The default disposition was append, meaning new rows were added without altering existing data.
Four checks were performed to ensure the data arrived correctly:
1. Rows per table comparison: The row counts matched between MySQL and PostgreSQL for all tables. This confirmed that no data was lost during the transfer.
2. Distinct keys check: Running the count of distinct IDs in the orders table showed that there were no duplicate rows. The second run revealed that the number of rows had doubled, indicating that every row was copied, but the keys were unchanged.
3. Value comparison: The SUM and SUM(quantity) queries confirmed that monetary values were accurately transferred without rounding errors, as the data types matched between MySQL and PostgreSQL.
4. Timestamp comparison: The earliest and latest timestamps were compared, ensuring they matched precisely to the second, taking into account the time zone differences between MySQL and PostgreSQL.
After verifying these checks, the data was deemed accurate and complete in the PostgreSQL database. The next steps involved applying any necessary transformations and considering the use of dbt adapters for MySQL, as Datanika does not maintain one.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to