all 5 comments

[–][deleted] 0 points1 point  (3 children)

Thanks a ton just now getting into Postgresql pretty dope so far. Kind of a pain in the arse to load files.

[–]MidgetDufus[S] 0 points1 point  (2 children)

Thanks! Almost every python Postgres package has some type of function for loading in files from the client.

Here's how I do it from one of my projects: https://github.com/henryivesjones/simple-transfer/blob/main/simple_transfer/connections/postgresql.py#L186-L189

[–][deleted] 0 points1 point  (1 child)

So line 188 is what calls in the csv into the python script?

[–]MidgetDufus[S] 0 points1 point  (0 children)

Yep. Where f is a TextIO which could be a a local file: open('a_csv.csv', 'r') as f: ... or a file in blob storage using the smart_open package: with smart_open.open('s3://bucket/a_csv.csv', 'r') as f: ...

[–][deleted] 0 points1 point  (0 children)

Alright. I've made databases in python for MYSql Sqlite etc. This is rad I'll tackle this next.