[web2py] Re: cpdb from sqlite to postgresql

2014-01-06 Thread Dave S
See below:


On Sunday, January 5, 2014 12:32:26 PM UTC-8, mweissen wrote:
>
>
> I want to change from sqlite to postgresql.
>
> At first I have installed postgresql and prepared everything as described 
> in the book. Next I have built a sample application
>  with a line like
>
> db1 = DAL("postgres://web2py:web2py123@localhost:5432/securedb")
>
> Works fine!
>
> Now I have tried cpdb ( I have broken the lines for better readablity):
>
> root@test:/home/www-data/web2py# python scripts/cpdb.py  
> -f applications/postgesql_test/databases 
> -y sqlite://storage.sqlite 
> -Y postgres://web2py:web2py123@localhost:5432/securedb 
> -d gluon/ 
> -t False
>
> The result is an error message:
>
> EXCEPTION: could not make a copy of the database
> Failure to connect, tried 5 times:
> Traceback (most recent call last):
>   File "gluon/dal.py", line 7766, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "gluon/dal.py", line 2756, in __init__
> if do_connect: self.find_driver(adapter_args,uri)
>   File "gluon/dal.py", line 795, in find_driver
> raise RuntimeError("no driver available %s" % str(self.drivers))
> RuntimeError: no driver available ('psycopg2', 'pg8000')
>
> Next try - a copy from sqlite to sqlite
>
> root@test:/home/www-data/web2py# python scripts/cpdb.py
>-f applications/postgresql_test/databases 
>-y sqlite://storage.sqlite 
>-Y sqlite://storage2.sqlite 
>-F applications/postgresql_test/databases 
>-d gluon/ -t False
>
> creating tables...
> exporting data...
> importing data...
> done!
>
> Ok, no problem - cpdb works.
> And now the interactive version:
>
> root@test:/home/www-data/web2py# python scripts/cpdb.py  
>-f applications/postgresql_test/databases 
>-y sqlite://storage.sqlite 
>-Y postgres://web2py:web2py123@localhost:5432/securedb 
>-d gluon/ -t False -i
>
> >>> t=DAL("postgres://web2yp:web2py123@localhost:5432/securedb", 
> folder=None)
> sorry, can not do that!
> Failure to connect, tried 5 times:
> Traceback (most recent call last):
>   File "gluon/dal.py", line 7766, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "gluon/dal.py", line 2756, in __init__
> if do_connect: self.find_driver(adapter_args,uri)
>   File "gluon/dal.py", line 795, in find_driver
> raise RuntimeError("no driver available %s" % str(self.drivers))
> RuntimeError: no driver available ('psycopg2', 'pg8000')
>
>
> I have tried DAL calls like DAL("postgres:psycopg2:") and 
> DAL("postgres:pg8000:") - similar results.
>
>
Did you copy the driver  into the working directory?  Recent versions of 
web2py ship with the handlers in a subdirectory (web2py/handlers), so they 
don't clobber any changes you made the last time you set them up.

/dps

 

-- 
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/groups/opt_out.


[web2py] Re: cpdb from sqlite to postgresql

2014-01-06 Thread Alan Etkin

>
> The result is an error message:
>>
>> EXCEPTION: could not make a copy of the database
>> Failure to connect, tried 5 times:
>> Traceback (most recent call last):
>>   File "gluon/dal.py", line 7766, in __init__
>> self._adapter = ADAPTERS[self._dbname](**kwargs)
>>   File "gluon/dal.py", line 2756, in __init__
>> if do_connect: self.find_driver(adapter_args,uri)
>>   File "gluon/dal.py", line 795, in find_driver
>> raise RuntimeError("no driver available %s" % str(self.drivers))
>> RuntimeError: no driver available ('psycopg2', 'pg8000')
>>
>
It seems that dal.py cannot import the drivers. Do you see any driver not 
found error log when you run the script? Also, can you import the driver 
with an interactive session?

-- 
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/groups/opt_out.


[web2py] Re: cpdb from sqlite to postgresql

2014-01-08 Thread Dave S
Martin  has sent the following:

On Tue, Jan 7, 2014 at 1:07 PM, Martin Weissenboeck wrote:

> Ok, I have found a solution.
>
> (1) I have to copy the whole directory /gluon to /scripts
> (2) Parameter -d of cpdb has to be an absolute path, e.g. -d 
> /home/www-data/web2py/gluon
>
> But I do not think that this is the best solution - maybe I habe to spend 
> some hours again.
>
> At the moment I do not understand why this works. 
> What I have found:
> - In dal.py the function find_driver expects 'pg8000' in globals() - but 
> it is not there.
> - Maybe there is a problem in def _getDal in file  cpdb.py ?
>
>  
 

-- 
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/groups/opt_out.