[PyGreSQL] Incomplete COPY from file

Marina Olhovsky olhovsky at mshri.on.ca
Wed Jan 24 19:42:50 EST 2007


Hello,

I am trying to load data into a PostgreSQL table by copying column values from a file using the COPY command.  The command is issued from within a Python script as follows:

[CODE]

fname = "/tmp/temp_file"
outfile = open(fame, 'w')

q1 = "SELECT DISTINCT my_id FROM tbl_1"
result = db.query(q1)
my_ids = result.getresult()

for i in my_ids:
  outfile.write(`i[0]` + '\n')

q2 = "COPY tbl_2(new_id) FROM '" + fname + "'"
db.query(q2)

[/CODE]

Both columns my_id in tbl_1 and new_id in tbl_2 are of type INTEGER, and the ids range from 1 to 78740.  All the ids from tbl_1 are being correctly written into the file (verified by viewing the file's contents).  However, when the script is executed, only ids 1 through 77510 are actually loaded into the table.  The same command works perfectly in the psql terminal: COPY tbl_2 (new_id) from '/tmp/temp_file' loads a complete list of ids from the file.

What could be the case?  Thank you so much for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.vex.net/pipermail/pygresql/attachments/20070124/ca905818/attachment.html 


More information about the PyGreSQL mailing list