PostgreSQL 10.2

132 views
Skip to first unread message

Rob Paire

unread,
Mar 1, 2018, 2:39:18 PM3/1/18
to web2py-users
Hello web2py community!

I am in the process of moving a 4 year old web2py application to a new server and I am having trouble getting the application to connect to PostgreSQL 10.2.  I am guessing because the version of psycopg2 driver in web2py is: 2.5.4 (dt dec pq3 ext) 

I installed the latest version of psycopg2 to my local Python installation and I can talk to the database, but how do I make web2py use the latest drivers? It is necessary to run from source to do this?   

Comments are appreciated.

Thank you for your help!
-Rob

Richard Vézina

unread,
Mar 1, 2018, 2:47:00 PM3/1/18
to web2py-users
Base on this : https://github.com/web2py/pydal/blob/466a39f13e443bbcc54db2d1ba6ed10196abf440/pydal/drivers.py#L45

web2py shouldn't enforce a specific version of psycopg2...

Are you using python 2 or python 3 and is your last psycopg2 version you mention is install for the python version that you use web2py with??

Richard

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

Anthony

unread,
Mar 1, 2018, 3:22:32 PM3/1/18
to web2py-users
If you have a local installation of Python, it is generally better to run web2py from source, as it will be able to use whatever Python packages you have installed on your system.

Anthony

Rob Paire

unread,
Mar 1, 2018, 3:32:14 PM3/1/18
to web2py-users
Hi Richard,
Thank you for your helpful reply. I am running the latest version of web2py 2_16_1. In order to query the version of psycpg2 which web2py is running put the following code into a view: 
{{import psycopg2}}
{{=psycopg2.__version__}}

This show web2py is running version  2.5.4 (dt dec pq3 ext)  


I used PIP to install the latest version of psycpg2: 2.7.4 into my local Python2.7 directory and I can talk to the database as expected. I am wondering how to get the latest version of Psycpg into web2py.

Error message below:.. note changing "localhost" to a server running postgres 9.3 everythings works fine.

Ticket ID

192.168.1.45.2018-03-01.15-25-12.2fa3bdd3-d668-4487-874a-3ca86557ad66

<type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: Traceback (most recent call last): File "C:\web2py_2_16_1\gluon\packages\dal\pydal\base.py", line 454, in __init__ self._adapter = adapter(**kwargs) File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 25, in __call__ return AdapterMeta.__call__(cls, *args, **kwargs) File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\__init__.py", line 40, in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 48, in __init__ driver_args, adapter_args, do_connect, after_connection) File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\base.py", line 368, in __init__ super(SQLAdapter, self).__init__(*args, **kwargs) File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\base.py", line 52, in __init__ self.reconnect() File "C:\web2py_2_16_1\gluon\packages\dal\pydal\helpers\classes.py", line 181, in _reconnect_and_configure self._connection_reconnect() File "C:\web2py_2_16_1\gluon\packages\dal\pydal\connection.py", line 172, in reconnect self.connection = self.connector() File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 105, in connector return self.driver.connect(**self.driver_args) File "psycopg2/__init__.py", line 164, in connect OperationalError: FATAL: database "booster_i" does not exist

Version

web2py™Version 2.16.1-stable+timestamp.2017.11.14.05.54.25

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
Traceback (most recent call last):
File "C:\web2py_2_16_1\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/web2py_2_16_1/applications/Booster_I/models/db.py", line 20, in <module>
db = DAL('postgres://username:password@localhost/booster_i',pool_size=1,check_reserved=['all'],migrate_enabled=False)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\base.py", line 169, in __call__
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\base.py", line 474, in __init__
"Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\base.py", line 454, in __init__
self._adapter = adapter(**kwargs)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 25, in __call__
return AdapterMeta.__call__(cls, *args, **kwargs)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\__init__.py", line 40, in __call__
obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 48, in __init__
driver_args, adapter_args, do_connect, after_connection)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\base.py", line 368, in __init__
super(SQLAdapter, self).__init__(*args, **kwargs)
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\base.py", line 52, in __init__
self.reconnect()
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\helpers\classes.py", line 181, in _reconnect_and_configure
self._connection_reconnect()
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\connection.py", line 172, in reconnect
self.connection = self.connector()
File "C:\web2py_2_16_1\gluon\packages\dal\pydal\adapters\postgres.py", line 105, in connector
return self.driver.connect(**self.driver_args)
File "psycopg2/__init__.py", line 164, in connect
OperationalError: FATAL: database "booster_i" does not exist


In file: C:\web2py_2_16_1\applications\Booster_I\models\db.py

1.
<code object <module> at 0C8CBA40, file "C:\web2py_2_16_1\applications\Booster_I\models\db.py", line 12>



On Thursday, March 1, 2018 at 2:39:18 PM UTC-5, Rob Paire wrote:

Anthony

unread,
Mar 1, 2018, 3:53:08 PM3/1/18
to web2py-users
Looks like it's finding the psycopg2 driver just fine -- the problem is that it is not finding a database named booster_i. You might need to specify the port in the connection string (e.g., "localhost:5432").

Anthony

Rob Paire

unread,
Mar 1, 2018, 3:58:52 PM3/1/18
to web...@googlegroups.com
Hi Anthony, 
Yes web2py PG driver works fine, except it is too old, doesn't support Postgres v10.2 
-Rob

--
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/YiXdSPqiiTo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Anthony

unread,
Mar 1, 2018, 4:40:19 PM3/1/18
to web2py-users
On Thursday, March 1, 2018 at 3:58:52 PM UTC-5, Rob Paire wrote:
Hi Anthony, 
Yes web2py PG driver works fine, except it is too old, doesn't support Postgres v10.2

web2py does not ship with the psycopg2 driver, so if your driver is out of date, it is up to you to update your system. If your system does not have psycopg2 installed, the DAL will default to the pure Python pg8000 driver that ships with the DAL, but according to your traceback, your app is using psycopg2, which must be coming from your system.

Anthony

Rob Paire

unread,
Mar 1, 2018, 5:35:59 PM3/1/18
to web2py-users
Anthony, 
This is surprising information, the server is brand new and all software is freshly installed. I will research further. Thank you for your help.

-Rob

Rob Paire

unread,
Mar 1, 2018, 6:36:40 PM3/1/18
to web2py-users
I am running the windows binary that is why PostgreSQL was working out of the box.

The Windows binary distribution works out of the box with SQLite, MSSQL, Postgresql and MySQL. The Mac binary distribution works out of the box with SQLite. To use any other database back-end, run from the source distribution and install the appropriate driver for the required back end.

Looks like the path forward is to run from source and upgrade the drivers. You guys were great - Thank you!
-Rob

Anthony

unread,
Mar 1, 2018, 6:38:48 PM3/1/18
to web2py-users
Have you restarted the web2py server since updating psycopg2? Do you only have one Python installation on the system?

Anthony

unread,
Mar 1, 2018, 8:55:32 PM3/1/18
to web...@googlegroups.com
On Thursday, March 1, 2018 at 6:36:40 PM UTC-5, Rob Paire wrote:
I am running the windows binary that is why PostgreSQL was working out of the box.

The Windows binary distribution works out of the box with SQLite, MSSQL, Postgresql and MySQL.

Now I see the Windows binary does include psycogp2 (the source version includes only pg8000). Assumed you had switched to running from source after this suggestion.

Anthony
Reply all
Reply to author
Forward
0 new messages