I am trying to use the function of copy_from in psycopy2 to insert data to my table named "ST_DAY_SRS",but how can I specified the schema named "NEW_CNYB"? I used the parmeter of option but it doesnot work ,please help me,thanks very much.
def action():
conn = psycopg2.connect(host='****',port='45432',
user='postgres',password='postgres',database='NEW_CNYB',options='-c search_path="NEW_CNYB"')
df = pd.DataFrame(l, columns=['ID', 'DATE', 'SUNRISE', 'SUNSET'])
ret=''
values_list=[]
for i in df.itertuples():
values_list.append('\t'.join([i[1],i[2],i[3],i[4]]))
for value in values_list:
ret += value + '\n'
print(ret)
cur = conn.cursor()
cur.copy_from(file=io.StringIO(ret),table="ST_DAY_SRS",
columns=("ID", "DATE", "SUNRISE", "SUNSET"))
conn.commit()