Using postgresql with py4web gives error

44 views
Skip to first unread message

Maurice Waka

unread,
Feb 19, 2020, 11:32:24 AM2/19/20
to web2py-users
I used this string to connect to postgresql database

db = DAL( "postgres://mauricewaka:b123test##@localhost:5432/mydb") 

as well as this

db = DAL( "postgres://mauricewaka:b123##@localhost/test")

But got this error:
Traceback (most recent call last):
  File "/home/maurice/py4web/py4web/core.py", line 846, in import_app
    module_name, init
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "apps/letsdo/__init__.py", line 28, in <module>
    db = DAL( "postgres://mauricewaka:b123test##@localhost/test")
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", line 208, in __call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", line 525, 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 "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", line 506, in __init__
    self._adapter = adapter(**kwargs)
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/postgres.py", line 28, in __call__
    return AdapterMeta.__call__(cls, *args, **kwargs)
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/__init__.py", line 41, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/postgres.py", line 67, in __init__
    after_connection,
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/base.py", line 417, in __init__
    super(SQLAdapter, self).__init__(*args, **kwargs)
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/base.py", line 86, in __init__
    self._initialize_()
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/postgres.py", line 113, in _initialize_
    self.get_connection()
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/connection.py", line 65, in get_connection
    connection = self.connector()
  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/adapters/postgres.py", line 134, in connector
    return self.driver.connect(**self.driver_args)
  File "/home/maurice/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?

E L

unread,
Feb 22, 2020, 8:38:09 AM2/22/20
to web...@googlegroups.com
If you are using ## in the password, that might cause problems for the
URL/URI parser since # is part of URL structure.
Otherwise, it looks like postgres is not running.


On Wed, Feb 19, 2020 at 10:32 AM Maurice Waka <mauri...@gmail.com> wrote:
>
> db = DAL( "postgres://mauricewaka:b123test##@localhost:5432/mydb")
> But got this error:
...
> RuntimeError: Failure to connect, tried 5 times:
...

Maurice Waka

unread,
Feb 22, 2020, 11:52:34 AM2/22/20
to web...@googlegroups.com
OK.
Thanks for the update. 
I reinstalled postgresql. 
I'll check performance. 
Regards 

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/8c2O5FoZIow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CAEVys%2BQXMzDM03niqtGHf7RdsEsH6hhuAyTQ_uU4uLub0Zf55A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages