I have a number of daily csv files to be imported into the Postgres. Below python codes work for importing a single csv file. How can I import batch cvs files? Thanks!
import psycopg2
con = psycopg2.connect(
database="xxxx",
user="xxxx",
password="xxxx",
host="xxxx")
cur = con.cursor()
file = open('path/to/directory/client_record_2020-01-01.csv', 'r')
next(file)
cur.copy_from(file, "table_name", columns=('col1', 'col2', 'col3', 'col4', 'col5'), sep=",")
con.commit()
con.close()