Hi John, some new info on the subject (there are comments inserted
between the session code) :
----------------------------------------------------------------------------------------------------------------
Platform: Win
Python Version: 2.5.2 on win32
Dabo Version: Version 0.9.1; Revision ~5057
UI Version: 2.8.8.1 on wxMSW
----------------------------------------------------------------------------------------------------------------

PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymssql
>>> pymssql.__version__
'0.8.0'
>>> conn = pymssql.connect(user='usr', password='pass', host='Host',
database='DBase')
>>> crsr = conn.cursor()
>>> dbName = u'tgestion'
>>> dbName
u'tgestion'
>>> crsr.execute("select table_name"
...             " from INFORMATION_SCHEMA.TABLES"
...             " where table_catalog = %(db)s"
...             " and table_type = 'BASE TABLE'"
...             " order by table_name",
...              {'db':dbName} )
Traceback (most recent call last):
  File "<input>", line 6, in <module>
  File "C:\Python25\lib\site-packages\pymssql.py", line 126, in execute
    self.executemany(operation, (params,))
  File "C:\Python25\lib\site-packages\pymssql.py", line 152, in executemany
    raise DatabaseError, "internal error: %s" % self.__source.errmsg()
DatabaseError: internal error: None
----------------------------------------------------------------------------------------------------------------
Note : This is the select that produces the dabo error message from
prior posts. It comes from dabo\db\dbMsSQL.py->getTables()
----------------------------------------------------------------------------------------------------------------
>>> crsr.execute("select table_name from INFORMATION_SCHEMA.TABLES where
table_catalog = %(db)s and table_type = 'BASE TABLE' order by
table_name"% {'db':dbName} )
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python25\lib\site-packages\pymssql.py", line 126, in execute
    self.executemany(operation, (params,))
  File "C:\Python25\lib\site-packages\pymssql.py", line 152, in executemany
    raise DatabaseError, "internal error: %s" % self.__source.errmsg()
DatabaseError: internal error: SQL Server message 207, severity 16,
state 3, line 1:
El nombre de columna 'tgestion' no es válido.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.
----------------------------------------------------------------------------------------------------------------
Notice "El nombre de columna 'tgestion' no es válido." means "The column
name 'tgestion' is not valid". That lead me to the following
----------------------------------------------------------------------------------------------------------------
>>> crsr.execute("select table_name from INFORMATION_SCHEMA.TABLES where
table_catalog = '%(db)s' and table_type = 'BASE TABLE' order by
table_name"% {'db':dbName} )
>>> class reg(object):
...     def __init__(self, cursor, registro):
...         for (attr, val) in zip((d[0] for d in cursor.description),
registro) :
...             setattr(self, attr, val)
...    
>>> for row in crsr.fetchall():
...     r = reg(crsr, row)
...     print r.table_name
...    
CposTablasVs
DatosTablasVs
datostablasvs1
dtproperties
TablasVs
>>>
----------------------------------------------------------------------------------------------------------------
So this one worked ok, differences : i) all in one line, ii) single
quotes around "%(db)s", and iii) use "%" instead of ","
----------------------------------------------------------------------------------------------------------------
>>> crsr.execute("select table_name from INFORMATION_SCHEMA.TABLES where
table_catalog = '%(db)s' and table_type = 'BASE TABLE' order by
table_name", {'db':dbName} )
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python25\lib\site-packages\pymssql.py", line 126, in execute
    self.executemany(operation, (params,))
  File "C:\Python25\lib\site-packages\pymssql.py", line 152, in executemany
    raise DatabaseError, "internal error: %s" % self.__source.errmsg()
DatabaseError: internal error: None
>>>
----------------------------------------------------------------------------------------------------------------
 So with "," instead of "%" is no good.
----------------------------------------------------------------------------------------------------------------
>>> crsr.execute("select table_name"+
...             " from INFORMATION_SCHEMA.TABLES"+
...             " where table_catalog = '%(db)s'"+
...             " and table_type = 'BASE TABLE'"+
...             " order by table_name"%
...              {'db':dbName} )
>>>
----------------------------------------------------------------------------------------------------------------
 Multinline statement does work
----------------------------------------------------------------------------------------------------------------

Maybe this can give you a clue about what's wrong with
dabo\db\dbMsSQL.py? It used to work once, but not any more.

TIA
Ricardo







_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to