I have not tested the performance, but maybe you can use something like this:
- Iterating over rows of a DataFrame, yielding a row representing the row (see below)
- Convert this iterable to stream using, for example, Python: convert iterable to stream?
- Finally, use psycopg
copy_from in this thread.
To get the rows of a DataFrame, effectively use something like:
def r(df): for idx, row in df.iterrows(): yield ','.join(map(str, row))
source share