0

There are 7 fields: id - char img - char phone - char date-date gender-char address_id - foreign key user_id - foreign key

I have written a script to load this in the postgres db, looks something like this:

conn = psycopg2.connect(user="user",
                        password="data",
                        host="",
                        port="5432",
                        database="")
cur = conn.cursor()


def load_data_on_db():
    with open(r'C:\Users\Documents\user.csv', 'r') as f:
        reader = csv.reader(f)

        #next(reader)  # Skip the header row.
        for row in reader:
            cur.execute(
                'INSERT INTO "CollectData_userdetails" VALUES (%s,%s,%s,%s,%s,%s,%s)',row)
        conn.commit()


load_data_on_db()

Throws an error

'INSERT INTO "CollectData_userdetails" VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)',row)

TypeError: not all arguments converted during string formatting

2
  • Is that not a duplicate ? stackoverflow.com/questions/40344690/… Commented Oct 17, 2019 at 11:43
  • it didnot work for me... throws no error but nothing gets loaded to the db Commented Oct 18, 2019 at 4:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.