December 30th, 2012, 10:00 PM
Insert records to Postgres from CSV string
I prepare a CSV string from desktop application and post it to a PHP script and it works fine.
Now I have to INSERT all records from a posted csv to the POSTGRES table, so ther would be some work with parsing csv variable to some array and then making a INSERTs to do the job.
Is there a better and more simple way to do it since I don't have a lot of experience in PHP?
December 31st, 2012, 02:33 AM
December 31st, 2012, 09:30 AM
Thank's, Jacques, I know it can be done directly within Postgres, but I post data via web, so PHP script is used to get the csv string from the web server.
Originally Posted by Jacques1
Or did you mean I should save CSV string somewhere as a temp file and do the rest of the job from Postgres?
December 31st, 2012, 11:43 PM
Um, so you have a desktop application, which sends a CSV string to a remote web server? Well, in this case keep your PHP script and use str_getcsv() to parse the CSV data.
Last edited by Jacques1; December 31st, 2012 at 11:57 PM.