copy Daten von CSV nach Postgresql mit Python

Ich bin auf Windows 7 64 Bit. Ich habe eine CSV-Datei 'data.csv'. Ich möchte Daten über ein Python-Skript in eine postgresql-Tabelle 'temp_unicommerce_status' importieren.

Mein Skript lautet:

import psycopg2
conn = psycopg2.connect("host='localhost' port='5432' dbname='Ekodev' user='bn_openerp' password='fa05844d'")
cur = conn.cursor()
cur.execute("""truncate table "meta".temp_unicommerce_status;""")
cur.execute("""Copy temp_unicommerce_status from 'C:\Users\n\Desktop\data.csv';""")
conn.commit()
conn.close()

Ich erhalte diesen Fehler

Traceback (most recent call last):
  File "C:\Users\n\Documents\NetBeansProjects\Unicommerce_Status_Update\src\unicommerce_status_update.py", line 5, in <module>
cur.execute("""Copy temp_unicommerce_status from     'C:\\Users\\n\\Desktop\\data.csv';""")
psycopg2.ProgrammingError: must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.

Antworten auf die Frage(14)

Ihre Antwort auf die Frage