Having a worksheet with ~20.000 rows of data, what is the best approach to insert those into a postgres database?
The table in which I will insert the data consists of many foreign keys, which means that I cannot simply insert this table with an approach as described here: Bulk Insert A Pandas DataFrame Using SQLAlchemy. Whilst I have values such as "Shoes", "Jacket", "Bag" etc. I need those to be in the form of the ID of a foreign table.
I can transform this data easily to a DataFrame with xlwings, but then I still have to figure out how to easily and quickly take care of the foreign key transformations.
E.g. Table 1:
product_id country product
1 USA Shoes
2 UK Jacket
3 GER Bag
E.g. Table 2:
user_id Name
1 John
2 Larry
3 Page
E.g. Table 3 (The one I'm uploading to):
order_id user product
1 3 2
2 2 2
3 1 1
And finally the table I have in excel:
user bought
John Shoes
Larry Shoes
Page Bag
Thanks!