Maybe your database in your other location is not empty when you import your
csv export file and as it says in the book :

When importing, the new records will be appended to the database if it is
not empty. In general the new imported records will not have the same record
id as the original (saved) records but web2py will restore references so
they are not broken, even if the id values may change.

So record already there can make your importation to failed on some
records...

Try to drop your new DB and recreate it from scratch and leave it empty
before try to import your CSV export from your orignial DB...

Maybe you can't do this with the web admin since you have to connect with a
user base on you app code so you need to create a admin user to execute
your

"db.import_from_csv_file(open('somefile.csv', 'rb'))"

command...

If it the case an other solution could be to start web2py with command line
and execute this command from the python terminal??

Richard


On Fri, Sep 30, 2011 at 10:48 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> pg_dump and pg_restore shouldn't cause any problem... I don't understand
> why it should... Maybe you should pg_dump with inserts command and when
> transfering your data they will be not re-indexed...
>
> Try this with pg_dump command :
>
> pg_dump --attribute-inserts > filename
>
> Richard
>
>
> On Fri, Sep 30, 2011 at 10:36 AM, Johann Spies <johann.sp...@gmail.com>wrote:
>
>> Following the advice in the book:
>>
>> In web2py, you can backup/restore an entire database with two commands:
>>
>> To export:
>>
>> 1.
>>
>> >>> db.export_to_csv_file(open('somefile.csv', 'wb'))
>>
>> To import:
>>
>> 1.
>>
>> >>> db.import_from_csv_file(open('somefile.csv', 'rb'))
>>
>>
>> I found the following when restoring:
>>
>> db.import_from_csv_file(open('/Users/js/Downloads/zenex_20110930.csv',
>> 'rb'))
>> Traceback (most recent call last):
>>   File "<console>", line 1, in <module>
>>   File "/Users/js/Programmeer/zenex/web2py/gluon/dal.py", line 4609, in
>> import_from_csv_file
>>     unique, *args, **kwargs)
>>   File "/Users/js/Programmeer/zenex/web2py/gluon/dal.py", line 5095, in
>> import_from_csv_file
>>     new_id = self.insert(**dict(items))
>>   File "/Users/js/Programmeer/zenex/web2py/gluon/dal.py", line 4976, in
>> insert
>>     return self._db._adapter.insert(self,self._listify(fields))
>>   File "/Users/js/Programmeer/zenex/web2py/gluon/dal.py", line 886, in
>> insert
>>     raise e
>> IntegrityError: insert or update on table "auth_membership" violates
>> foreign key constraint "auth_membership_user_id_fkey"
>> DETAIL:  Key (user_id)=(23) is not present in table "auth_user".
>>
>> and this presents me with serious problems.  It seems that the only way to
>> be able to duplicate a database on a another server will be to use uuid's.
>>
>> I have also tried a pg_dump of the whole database and pg_restore on the
>> other computer and all the cross references were messed up.
>>
>> Regards
>> Johann
>>
>> --
>>  May grace and peace be yours in abundance through the full knowledge of
>> God and of Jesus our Lord!  His divine power has given us everything we need
>> for life and godliness through the full knowledge of the one who called us
>> by his own glory and excellence.
>>                                                     2 Pet. 1:2b,3a
>>
>>
>

Reply via email to