Dataframe to postgresql - Saving the dataframe to memory using StringIO

Chris Angelico rosuav at gmail.com
Thu Oct 22 08:34:41 EDT 2020


On Thu, Oct 22, 2020 at 8:28 PM Shaozhong SHI <shishaozhong at gmail.com> wrote:
>
> I found this last option is very interesting.
>
> Saving the dataframe to memory using StringIO
>
> https://naysan.ca/2020/06/21/pandas-to-postgresql-using-psycopg2-copy_from/
>
> But, testing shows
> unicode argument expected, got 'str'
>
> Any working example for getting DataFrame into a PostgreSQL table directly?
>

That error suggests that you're using a legacy version of Python. The
page you're linking to has been written on the assumption that you're
using Python 3.

ChrisA


More information about the Python-list mailing list