Connect to Sybase ASE 15.7

301 views
Skip to first unread message

Anton Saltaev

unread,
Dec 16, 2014, 7:53:12 AM12/16/14
to web...@googlegroups.com
Hi
Try to connect Sybase ASE 15.7
Edit db.py
db = DAL('sybase://user:password@server/db_name')
When the application starts getting error:

<type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: Traceback (most recent call last): File "gluon/dal.py", line 8038, in __init__ File "gluon/dal.py", line 700, in __call__ File "gluon/dal.py", line 3849, in __init__ File "gluon/dal.py", line 659, in reconnect File "gluon/dal.py", line 3846, in connector TypeError: connect() got an unexpected keyword argument 'password'


What is the problem?

Leonel Câmara

unread,
Dec 16, 2014, 10:20:41 AM12/16/14
to web...@googlegroups.com
In the DAL's SybaseAdapter if you change this line:

            driver_args.update(user = credential_decoder(user),
                               password = credential_decoder(password))

to:

            driver_args.update(user = credential_decoder(user),
                               passwd = credential_decoder(password))

Does it work?

Anton Saltaev

unread,
Dec 18, 2014, 3:51:25 AM12/18/14
to web...@googlegroups.com
Now issued another error
<type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: Traceback (most recent call last): File "D:\programms\web2py\gluon\dal.py", line 8041, in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File "D:\programms\web2py\gluon\dal.py", line 700, in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File "D:\programms\web2py\gluon\dal.py", line 3852, in __init__ if do_connect: self.reconnect() File "D:\programms\web2py\gluon\dal.py", line 659, in reconnect self.connection = f() File "D:\programms\web2py\gluon\dal.py", line 3849, in connector return self.driver.connect(dsn, **driver_args) File "D:\programms\web2py\gluon\Sybase.py", line 1401, in connect datetime, bulkcopy, locale, inputmap, outputmap) File "D:\programms\web2py\gluon\Sybase.py", line 1035, in __init__ self.connect() File "D:\programms\web2py\gluon\Sybase.py", line 1084, in connect status = conn.ct_connect(self.dsn) File "D:\programms\web2py\gluon\Sybase.py", line 265, in _clientmsg_cb raise DatabaseError(msg) DatabaseError: Layer: 6, Origin: 8 ct_connect(): directory service layer: internal directory control layer error: Requested server name not found.

If you establish a connection from the console python, the connection is established successfully
>>> import Sybase
>>> Sybase.connect('dibrera','user','password','dbname')
Connection(16260352)
>>>

вторник, 16 декабря 2014 г., 19:20:41 UTC+4 пользователь Leonel Câmara написал:

Paolo Valleri

unread,
Dec 18, 2014, 4:09:31 AM12/18/14
to web...@googlegroups.com
Which version of web2py are you using? I don't have the Sybase.py file in gluon. Have you split mssql.py ?
Please post some code and add a print statement for the dns variable in SysbaseAdapter in order to understand what is going wrong.

Paolo

Leonel Câmara

unread,
Dec 18, 2014, 1:22:57 PM12/18/14
to web...@googlegroups.com
Apart from the bug we have uncovered earlier, you now seem to have a sybase configuration problem, I don't use Sybase but this seems to be the common solution:

isi_jca

unread,
Nov 2, 2018, 3:59:13 PM11/2/18
to web2py-users
Hi!!!

I get this message when try to connect at sybase (ASE)

Ticket ID

127.0.0.1.2018-11-02.16-39-39.0e1ecf1e-e9a8-4950-893f-e3c2b7a98b0b

<type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: Traceback (most recent call last):
File "c:\web2py\gluon\packages\dal\pydal\base.py", line 455, in __init__ self._adapter = adapter(**kwargs)
File "c:\web2py\gluon\packages\dal\pydal\adapters\__init__.py", line 40, in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
File "c:\web2py\gluon\packages\dal\pydal\adapters\mssql.py", line 31, in __init__ driver_args, adapter_args, do_connect, after_connection)
File "c:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 369, in __init__ super(SQLAdapter, self).__init__(*args, **kwargs)
File "c:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 53, in __init__ self.reconnect()
File "c:\web2py\gluon\packages\dal\pydal\connection.py", line 152, in reconnect self.connection = self.connector()
File "c:\web2py\gluon\packages\dal\pydal\adapters\mssql.py", line 184, in connector return self.driver.connect(self.dsn, **self.driver_args)
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and
no default driver specified (0) (SQLDriverConnect)')

Version
web2py™     Version 2.17.2-stable+timestamp.2018.10.06.18.54.02


I made this test using:


db = DAL('sybase://myuser:Pa$$w0rd@myserver/mydatabase',check_reserved=['all'])
db = DAL('sybase://myuser:Pa$$w0rd@myserver:5000/mydatabase',check_reserved=['all'])
db = DAL('sybase://myuser:Pa$$w0rd@<ip>/mydatabase',check_reserved=['all'])
db = DAL('sybase://myuser:Pa$$w0rd@<ip>:5000/mydatabase',check_reserved=['all'])

But in all case web2py show the same message. What is the problem?.

Thanks in advance.

黄祥

unread,
Nov 2, 2018, 6:16:53 PM11/2/18
to web2py-users
from error traceback seems like an error with database connection (Data source name not found and no default driver), 
for Data source name pls check you've already define it. if i'm not wrong in Control Panel > Administrative Tools > Data Source (ODBC), then restart web2py
for no driver, perhaps you can install the sybase driver for python first, then restart web2py server

best regards,
stifan

isi_jca

unread,
Apr 25, 2019, 7:51:56 AM4/25/19
to web2py-users
Using Python native module in SDK ASE 16, the connection is sucessful

 import sybpydb
 conn = sybpydb.connect(servername='TEST',user='Myuser', password='Pa$$w0rd')
 cur = conn.cursor()
 cur.execute("select succod, sucdesc from mydb..tsucursal")
 while True:
     row = cur.fetchone()
     if (not row):
        break
        print("%s: %s" % (row[0], row[1]))
     else:
         print('Sucursal',row[0],'Descripcion',row[1])
 cur.close()
conn.close()


/*======================================================================================================*/
From web2py, I am using 'mssql' intead of 'sybase' because sybase has not DSN attribute.

db = DAL('mssql://DSN=SERVERTEST',check_reserved=['all'])
 
 <class 'pyodbc.ProgrammingError'> ('42000', "[42000] [SAP][ASE ODBC Driver][Adaptive Server Enterprise]Incorrect syntax near '('.\n (102) (SQLExecDirectW)")
 Version
 web2py™     Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
 Python     Python 2.7.8: C:\Python27\python.exe (prefix: C:\Python27)
 Traceback

 
 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 219, in restricted
     exec(ccode, environment)
   File "C:\web2py\applications\StatusWeb\models\db.py", line 98, in <module>
     auth.define_tables(username=False, signature=False)
   File "C:\web2py\gluon\tools.py", line 2092, in define_tables
     super(Auth, self).define_tables(username, signature, migrate, fake_migrate)._table_signature_list
   File "C:\web2py\gluon\authapi.py", line 350, in define_tables
     format='%(first_name)s %(last_name)s (%(id)s)'))
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 592, in define_table
     table = self.lazy_define_table(tablename, *fields, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 626, in lazy_define_table
     polymodel=polymodel)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 798, in create_table
     return self.migrator.create_table(*args, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\migrator.py", line 281, in create_table
     self.adapter.create_sequence_and_triggers(query, table)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 881, in create_sequence_and_triggers
     self.execute(query)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\__init__.py", line 67, in wrap
     return f(*args, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 413, in execute
     rv = self.cursor.execute(command, *args[1:], **kwargs)
 ProgrammingError: ('42000', "[42000] [SAP][ASE ODBC Driver][Adaptive Server Enterprise]Incorrect syntax near '('.\n (102) (SQLExecDirectW)")
 
 Error snapshot help
 
 <class 'pyodbc.ProgrammingError'>(('42000', "[42000] [SAP][ASE ODBC Driver][Adaptive Server Enterprise]Incorrect syntax near '('.\n (102) (SQLExecDirectW)"))
 
 inspect attributes
 Frames
 
     File C:\web2py\gluon\restricted.py in restricted at line 219 code arguments variables
 
     File C:\web2py\applications\StatusWeb\models\db.py in <module> at line 98 code arguments variables
 
     File C:\web2py\gluon\tools.py in define_tables at line 2092 code arguments variables
 
     File C:\web2py\gluon\authapi.py in define_tables at line 350 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\base.py in define_table at line 592 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\base.py in lazy_define_table at line 626 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in create_table at line 798 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\migrator.py in create_table at line 281 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in create_sequence_and_triggers at line 881 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\adapters\__init__.py in wrap at line 67 code arguments variables
 
     File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in execute at line 413 code arguments variables
     Function argument list
 
     (self=<pydal.adapters.mssql.MSSQL1 object>, *args=('CREATE TABLE "auth_user"(\n "id" INT IDENTITY ... NULL,\n "registration_id" VARCHAR(512) NULL\n);',), **kwargs={})
     Code listing
 
    
 
         def execute(self, *args, **kwargs):
             command = self.filter_sql_command(args[0])
             handlers = self._build_handlers_for_execution()
             for handler in handlers:
                 handler.before_execute(command)
             rv = self.cursor.execute(command, *args[1:], **kwargs)
             for handler in handlers:
                 handler.after_execute(command)
             return rv
 
     Variables
     rv     undefined
     self     <pydal.adapters.mssql.MSSQL1 object>
     args     ('CREATE TABLE "auth_user"(\n "id" INT IDENTITY ... NULL,\n "registration_id" VARCHAR(512) NULL\n);',)
     self.cursor     <pyodbc.Cursor object>
     command     'CREATE TABLE "auth_user"(\n "id" INT IDENTITY ... NULL,\n "registration_id" VARCHAR(512) NULL\n);'
     self.cursor.execute     <built-in method execute of pyodbc.Cursor object>
     kwargs     {}
 
 
 locals request session response
 In file: C:\web2py\applications\StatusWeb\models\db.py
 
    
 
 <code object <module> at 000000000AC03D30, file "C:\web2py\applications\StatusWeb\models\db.py", line 7>

Any suggestions?

Best regards.
Reply all
Reply to author
Forward
0 new messages