Odoo Help


How to execute python-script for importing products directly to postgresql

on 9/3/14, 11:48 AM 5,633 views

I Kept this python file as well as csv file in server-folder. But it's not importing products!

Python Script-

import csv
import psycopg2

conn_string = "dbname= 'toc' user='openerp' password='sigma@123'"

conn = psycopg2.connect(conn_string)
cursor = conn.cursor()

reader = csv.reader(open('prod.csv','rb'))

for row in reader:
    print row[1]
    statement = "INSERT INTO product_template (name,description) VALUES ('" +row[1]+"','" +(row[2])+"') RETURNING id"
    statement = "INSERT INTO product_product (product_tmpl_id,default_code,active,valuation) VALUES \
    (" + str(templateid) + ",'" + row[0] + "',True,'manual_periodic')"

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/3/14, 11:48 AM
Seen: 5633 times
Last updated: 3/16/15, 8:10 AM