DAL connect to oracle database

120 views
Skip to first unread message

cabingco

unread,
Jan 10, 2022, 8:10:32 PM1/10/22
to py4web
   oracle= DAL(uri="oracle://immat/immay@cilog1_sosgua") File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\base.py", line 215, in __call__ obj = super(MetaDAL, cls).__call__(*args, **kwargs) File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\base.py", line 537, in __init__ raise RuntimeError( RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\base.py", line 515, in __init__ self._adapter = adapter(**kwargs) File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\adapters\__init__.py", line 41, in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\adapters\base.py", line 424, in __init__ super(SQLAdapter, self).__init__(*args, **kwargs) File "c:\users\kboka\appdata\local\programs\python\python38\lib\site-packages\pydal\adapters\base.py", line 86, in __init__ self._initialize_() TypeError: _initialize_() missing 1 required positional argument: 'do_connect'

Massimo

unread,
Jan 13, 2022, 1:20:44 AM1/13/22
to py4web
What version do you have? There should not be do_connect.

Angelo Raho

unread,
Jan 13, 2022, 11:31:53 AM1/13/22
to py4web

The problem is the same of this issue of pydal, 



Greetings
Angelo

Massimo

unread,
Jan 13, 2022, 10:11:43 PM1/13/22
to py4web
But this all appear to be fixed.
Is cabingo using an old pydal?
I do not understand.

Angelo Raho

unread,
Jan 14, 2022, 6:16:31 AM1/14/22
to py4web
Yes may be old but in the setup.py file of py4web there is


install_requires=[
"wheel",
"ombott >= 0.0.10",
"click",
"colorama",
"cryptography",
"portalocker",
"tornado",
"renoir >= 1.4.0",
"requests",
"threadsafevariable >= 1.2",
"pyjwt >= 2.0.1",
"pluralize >= 0.1.8",
"rocket3",
"yatl >= 20211217.1",
"pydal >= 20210626.3",
"watchgod >= 0.6", ]

The    20210626.3 have the file  pydal/pydal/adapters/oracle.py  with

"
...

def _initialize_(self, do_connect):


super(Oracle, self)._initialize_(do_connect)

...

"

then, for me, the issue

Greetings  
Angelo

Massimo

unread,
Jan 14, 2022, 10:19:03 PM1/14/22
to py4web
Will fix that. Thanks for checking it.

cabingco

unread,
Jan 17, 2022, 8:11:34 PM1/17/22
to py4web
sorry for being absent
arma...@gmail.com is right
find below, my version 
Py4web: 1.20220106.1 on Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
i think, i have the new version of baseAdapter class 
  def __init__(
        self,
        db,
        uri,
        pool_size=0,
        folder=None,
        db_codec="UTF-8",
        credential_decoder=IDENTITY,
        driver_args={},
        adapter_args={},
        after_connection=None,
        entity_quoting=False,
    ):
        super(BaseAdapter, self).__init__()
        self._load_dependencies()
        self.db = db
        self.uri = uri
        self.pool_size = pool_size
        self.folder = folder
        self.db_codec = db_codec
        self.credential_decoder = credential_decoder
        self.driver_args = driver_args
        self.adapter_args = adapter_args
        self.expand = self._expand
        self._after_connection = after_connection
        self.set_connection(None)
        self.find_driver()
        self._initialize_()

however, my    pydal/pydal/adapters/oracle.py file contains the mistake 
and i modified it , commenting out the faulty lines

@adapters.register_for("oracle")
class Oracle(SQLAdapter):
    dbengine = "oracle"
    drivers = ("cx_Oracle",)

 #   cmd_fix = re.compile("[^']*('[^']*'[^']*)*\:(?P<clob>(C|B)LOB\('([^']+|'')*'\))")
    REGEX_CLOB = re.compile("[^']*('[^']*'[^']*)*\:(?P<clob>(C|B)LOB\('([^']+|'')*'\))")

    def _initialize_(self):
        super(Oracle, self)._initialize_()
    #def _initialize_(self, do_connect):
    #   super(Oracle, self)._initialize_(do_connect)


great thanks  to  arma...@gmail.com
the issue is fixed for me, 
but i can not find my oracle database existing tables !!!

>>> db=DAL('oracle://immat:immat@cilog1:1525/sosgua')
>>> db.tables
[]

what have i missed here ?

Kevin Keller

unread,
Jan 18, 2022, 12:37:01 AM1/18/22
to cabingco, py4web
Will try to reproduce today 

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/61cd696d-fdf9-4448-a0da-18f864f09d5cn%40googlegroups.com.

Massimo DiPierro

unread,
Jan 18, 2022, 12:58:13 AM1/18/22
to cabingco, py4web
db = DAL(...)
Tells pydal how to connect to the database not what is there.

db.define_table('thing'...)
Tells pydal you need a table thing and it will create if it was not created already. It keeps a record of what tables were created.

You need to define your tables even if they exist. If they were not created by pydal you need fake_migrate=True
So it thinks it did.

--
Reply all
Reply to author
Forward
0 new messages