[web2py] Re: SQlite to Postgres insert problems

2015-11-19 Thread Carla Raquel
Problem solved!Everything is working fine now!

quarta-feira, 18 de Novembro de 2015 às 15:35:32 UTC, Carla Raquel escreveu:
>
> I'm having some troubles importing from csv files while using a Postgres 
> connection, when a table has one or more references to other tables like so:
>
> db.define_table('Extension',
> Field('Person',db.auth_user),
> Field('Supervisor',db.auth_user),
> Field('Number','integer'),
> Field('Description','text')
>
>
>
> I have created this and the auth_user table on Postgres and imported the 
> auth_user contents from the csv file with no problems. I also have no 
> problems importing to other tables that have no external references. I have 
> the following error: ('Error', '23503','insert or update on table 
> "extensao" violates foreign key constraint "extension_person_fkey"'). Any 
> ideas?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQlite to Postgres insert problems

2015-11-18 Thread Anthony
You can use the method to export/import the all tables at once 

 
- that will handle all the references automatically. If you want to limit 
it to a subset of the tables, just run the export/import commands after 
defining only those tables (any tables not yet defined will be invisible to 
the DAL and therefore won't be exported/imported).

Anthony

On Wednesday, November 18, 2015 at 10:35:32 AM UTC-5, Carla Raquel wrote:
>
> I'm having some troubles importing from csv files while using a Postgres 
> connection, when a table has one or more references to other tables like so:
>
> db.define_table('Extension',
> Field('Person',db.auth_user),
> Field('Supervisor',db.auth_user),
> Field('Number','integer'),
> Field('Description','text')
>
>
>
> I have created this and the auth_user table on Postgres and imported the 
> auth_user contents from the csv file with no problems. I also have no 
> problems importing to other tables that have no external references. I have 
> the following error: ('Error', '23503','insert or update on table 
> "extensao" violates foreign key constraint "extension_person_fkey"'). Any 
> ideas?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: sqlite to postgres

2012-03-29 Thread Wikus van de Merwe
Upgrade. Python 2.7 is backward compatible with 2.6. Pip install is also a 
good option.


Re: [web2py] Re: sqlite to postgres

2012-03-28 Thread Massimo Di Pierro
true. cpdb was rewrtten and requires 2.7. I think it is the only 
module/script that requires 2.7.

On Wednesday, 28 March 2012 17:43:48 UTC-5, Marco Tulio wrote:
>
> That sounds what I need 
>
> but:
>
> ubuntu@ip:/home/www-data/web2py$ python scripts/cpdb.py -h
> Traceback (most recent call last):
>   File "scripts/cpdb.py", line 5, in 
> import argparse
> ImportError: No module named argparse
>
> then I read somewhere this:
>
>   
> 1down vote
>  
> The argparse module was added in Python 2.7. 
> http://docs.python.org/library/argparse.html
>
> Prior to 2.7, the most common way to handle command-line arguments was 
> probably getopt.http://docs.python.org/library/getopt.html
>
> Of course you can always handle the command-line manually simply by 
> looking at sys.argv. Howevergetopt is a good abstraction layer, and 
> argparse is even better.
>
> If you truly need argparse in older environments (debatable), there is a 
> Google Code project maintaining it, and you can include that in your 
> project. http://code.google.com/p/argparse/
>   link |improve this 
> answer
>  
> from: 
> http://stackoverflow.com/questions/7473609/argparse-python-modules-in-cli
>
> And I'm like: 
> ubuntu@ip:~$ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 
>
> wich means it doesn't work because I just don't have it.
>
> someone said this:
>
>   up vote3down vote
>  
> Well if the only thing you need is argparse (saw that in one of your 
> comments!) you could just do :
>
> pip install argparse
>
> This is not exactly an answer to the exact question :-) , but indeed if 
> you are only missing a few feature, many 2.7 features actually come from 
> independent projects and/or some compatibility packages can be found, eg:
>
>
> Also from:  
> http://stackoverflow.com/questions/7473609/argparse-python-modules-in-cli
>
> wich made me think that I'm using 2.6 while there's 2.7 and 3.2 out 
> there... should I consider upgrading python to a newer version or just get 
> the missing module?
>
> Thanks in advanced!
> Marco Tulio
>
> 2012/3/27 nick name 
>
>> On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote:
>>
>>> How do I get the data that was on my app (on the sqlite database).
>>
>>
>> Web2py comes with scripts/cpdb.py, which copies databases from one 
>> connection string to another with lots of other goodies.
>>
>> see 
>> http://web2py.com/books/default/chapter/29/6#Copy-data-from-one-db-into-another(if
>>  it doesn't get you to the right place, look for "cpdb" in the page)
>>
>
>
>
> -- 
> []'s
> Marco Tulio
>  


Re: [web2py] Re: sqlite to postgres

2012-03-28 Thread Marco Tulio Cicero de M. Porto
seems to work, but I still couldn't make it work on my project (worked well
on smaller projects though)

2012/3/27 Anthony 

> http://web2py.com/books/default/chapter/29/6#CSV-(all-tables-at-once)
>
>
> On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote:
>>
>> Hi!
>>
>> I was using sqlite as my database for a few projects, but decided to go
>> to postgres.
>>
>> While to web2py going from one to another is pretty much a connection
>> string that you'll change, there's still one problem remaining.
>>
>> How do I get the data that was on my app (on the sqlite database).
>>
>> On a small application, I managed to do that by exporting a csv file on
>> the old app and importing it on the new one. And that's it.
>>
>> But I have another app that has quite a few tables now... wich means that
>> I'd have to copy several cvs and import them.
>>
>> Question is: isn't there an easier way to do it? (to backup a sqlite
>> database and restore it as postgres in one piece?)
>>
>> If there isn't, that means that worst case scenario, I'll have to
>> export/import csv's corresponding to my tables. I can do that...
>> but there really isn't another way ?
>>
>> Thanks!
>> --
>> []'s
>> Marco Tulio
>>
>>


-- 
[]'s
Marco Tulio


Re: [web2py] Re: sqlite to postgres

2012-03-28 Thread Marco Tulio Cicero de M. Porto
That sounds what I need

but:

ubuntu@ip:/home/www-data/web2py$ python scripts/cpdb.py -h
Traceback (most recent call last):
  File "scripts/cpdb.py", line 5, in 
import argparse
ImportError: No module named argparse

then I read somewhere this:


1down vote

The argparse module was added in Python 2.7.
http://docs.python.org/library/argparse.html

Prior to 2.7, the most common way to handle command-line arguments was
probably getopt.http://docs.python.org/library/getopt.html

Of course you can always handle the command-line manually simply by looking
at sys.argv. Howevergetopt is a good abstraction layer, and argparse is
even better.

If you truly need argparse in older environments (debatable), there is a
Google Code project maintaining it, and you can include that in your
project. http://code.google.com/p/argparse/
link |improve this
answer

from:
http://stackoverflow.com/questions/7473609/argparse-python-modules-in-cli

And I'm like:
ubuntu@ip:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

wich means it doesn't work because I just don't have it.

someone said this:

up vote3down vote

Well if the only thing you need is argparse (saw that in one of your
comments!) you could just do :

pip install argparse

This is not exactly an answer to the exact question :-) , but indeed if you
are only missing a few feature, many 2.7 features actually come from
independent projects and/or some compatibility packages can be found, eg:


Also from:
http://stackoverflow.com/questions/7473609/argparse-python-modules-in-cli

wich made me think that I'm using 2.6 while there's 2.7 and 3.2 out
there... should I consider upgrading python to a newer version or just get
the missing module?

Thanks in advanced!
Marco Tulio

2012/3/27 nick name 

> On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote:
>
>> How do I get the data that was on my app (on the sqlite database).
>
>
> Web2py comes with scripts/cpdb.py, which copies databases from one
> connection string to another with lots of other goodies.
>
> see
> http://web2py.com/books/default/chapter/29/6#Copy-data-from-one-db-into-another(if
>  it doesn't get you to the right place, look for "cpdb" in the page)
>



-- 
[]'s
Marco Tulio


[web2py] Re: sqlite to postgres

2012-03-27 Thread nick name
On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote:
>
> How do I get the data that was on my app (on the sqlite database).


Web2py comes with scripts/cpdb.py, which copies databases from one 
connection string to another with lots of other goodies.

see 
http://web2py.com/books/default/chapter/29/6#Copy-data-from-one-db-into-another 
(if it doesn't get you to the right place, look for "cpdb" in the page)


[web2py] Re: sqlite to postgres

2012-03-27 Thread Anthony
http://web2py.com/books/default/chapter/29/6#CSV-(all-tables-at-once)


On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote:
>
> Hi!
>
> I was using sqlite as my database for a few projects, but decided to go to 
> postgres.
>
> While to web2py going from one to another is pretty much a connection 
> string that you'll change, there's still one problem remaining. 
>
> How do I get the data that was on my app (on the sqlite database). 
>
> On a small application, I managed to do that by exporting a csv file on 
> the old app and importing it on the new one. And that's it. 
>
> But I have another app that has quite a few tables now... wich means that 
> I'd have to copy several cvs and import them. 
>
> Question is: isn't there an easier way to do it? (to backup a sqlite 
> database and restore it as postgres in one piece?)
>
> If there isn't, that means that worst case scenario, I'll have to 
> export/import csv's corresponding to my tables. I can do that... 
> but there really isn't another way ?
>
> Thanks!
> -- 
> []'s
> Marco Tulio
>
>