db.import_from_csv_file(open('pg_file2.csv', 'rb'))

I tried running above in SHELL but could not find error messages.  So I ran 
it in a function in default.py

I got  <class 'psycopg2.IntegrityError'> insert or update on table 
"auth_user" violates foreign key constraint "auth_user_created_by_fkey" 
DETAIL: Key (created_by)=(1) is not present in table "auth_user".

then I tried making sure constraints were removed but raised same error 
(ran the below in a function in default.py).

    pgdb = DAL('postgres://postgres:PASWORD@localhost:5432/pg_for_es')
    for tablename in pgdb.tables():
        pgdb.executesql("ALTER TABLE %s DISABLE TRIGGER ALL;" % tablename)
    db.import_from_csv_file(open('pg_file2.csv', 'rb'))
    for tablename in pgdb.tables():
        pgdb.executesql("ALTER TABLE %s ENABLE TRIGGER ALL;" %  tablename)

any ideas on how to import without constraints enabled?

thanks

Alex Glaros


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to