Skip to content

Commit

Permalink
Merge pull request #21 from shradayshakya/example-enhancement
Browse files Browse the repository at this point in the history
Print number of rows transferred
  • Loading branch information
kabirbaidhya authored Oct 27, 2019
2 parents ae27a97 + a8ec510 commit 985e685
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/data-transfer-pg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ app_1 | Create fruits table and populate data in source database.
app_1 | Create fruits table in destination database.
app_1 | Extracting fruits data from source database.
app_1 | Transferring fruits data to destination database.
app_1 | Transferred 3 rows of fruits data from source database to destination database.
app_1 | Display fruits data in destination database.
app_1 | ID NAME QUANTITY
app_1 | --------------------------------
app_1 | 1 Banana 150
app_1 | 2 Orange 64
app_1 | 3 Apple 35
app_1 | 3 Apple 35
```
2 changes: 2 additions & 0 deletions examples/data-transfer-pg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def transfer_data(source_db_cursor, dest_db_cursor, dest_db_conn):
for row in rows:
dest_db_cursor.execute('INSERT INTO fruits VALUES (?, ?, ?)', (row.id, row.name, row.quantity))
dest_db_conn.commit()

print(f"Transferred {len(rows)} rows of fruits data from source database to destination database.")


def display_fruits(db_cursor):
Expand Down

0 comments on commit 985e685

Please sign in to comment.