Hi,
We are trying to insert the data from a text file 'some_category_list.txt'' into a table in Postgres database using the highlighted query in our functions.py
file = open(str(a)+'_category_list.txt', 'r')
file_content = file.read()
print(file_content)
file.close()
from django.db import connection
cursor = connection.cursor()
query = "COPY pages_rim_ls_categories FROM '{0}_category_list.txt' WITH DELIMITER AS '|'".format(str(a))
cursor.execute(query)
and we are getting this error
django.db.utils.OperationalError:
could not open file "some_category_list.txt" for reading: No such file
or directory
HINT: COPY FROM instructs the PostgreSQL server process to read a file.
You may want a client-side facility such as psql's \copy.
Note: We used below query in the past using MySQL and it worked fine with that.
query = "LOAD DATA LOCAL INFILE 'some_category_list.txt' INTO TABLE
pages_rim_ls_categories FIELDS TERMINATED BY '|' LINES TERMINATED BY
'\n' "
We are wondering what we are missing. Could someone help here to verify this?
Best regards
~Ram