Hi,

I have a weird issue wherein I send a unicode string to SQL Server
2000 using SqlAlchemy in a wxPython program. A little history would
probably help: I created a timesheet program last year using wxPython
and connected to my databases using pymssql. In the hopes of making
this program more flexible and efficient, I decided to switch to
SqlAlchemy.

In my program, I can view 26 separate time periods that show the
user's time worked. To tell what period I am in, I grab the title of
the wx frame. I store this in one of my tables so that the next time
the user opens their timesheet, it will open to the last opened time
period. Anyway, it appears that the wxPython returns the title as a
unicode string.

When I try to commit this string to my database, SqlAlchemy blows up
and gives me this huge traceback:

Traceback (most recent call last):
  File "\\debianis\loginscript$\PythonPackages\Development
\Timesheet_sa
\ts_worksheet_MT.py", line 689, in onClose
    session.flush()
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\session.py", line 789, in flush
    self.uow.flush(self, objects)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\unitofwork.py", line 233, in flush
    flush_context.execute()
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\unitofwork.py", line 445, in execute
    UOWExecutor().execute(self, tasks)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\unitofwork.py", line 930, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\unitofwork.py", line 945, in execute_save_steps
    self.save_objects(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\unitofwork.py", line 936, in save_objects
    task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\orm\mapper.py", line 1144, in _save_obj
    c = connection.execute(statement.values(value_params), params)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 844, in execute
    return Connection.executors[c](self, object, multiparams, params)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 895, in execute_clauseelement
    return self._execute_compiled(elem.compile(dialect=self.dialect,
column_keys=keys, inline=len(params) > 1), distilled_params=params)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 907, in _execute_compiled
    self.__execute_raw(context)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 916, in __execute_raw
    self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 960, in _cursor_execute
    self._handle_dbapi_exception(e, statement, parameters, cursor)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.7-py2.5.egg
\sqlalchemy\engine\base.py", line 942, in _handle_dbapi_exception
    raise exceptions.DBAPIError.instance(statement, parameters, e,
connection_invalidated=is_disconnect)
sqlalchemy.exceptions.DatabaseError: (DatabaseError) internal error:
None 'UPDATE [tbl_Acct_Prefs] SET pref_value=%(pref_value)s WHERE
[tbl_Acct_Prefs].[empID] = %(tbl_Acct_Prefs_empID)s AND
[tbl_Acct_Prefs].pref_name = %
(tbl_Acct_Prefs_pref_name)s' {'pref_value': u'4',
'tbl_Acct_Prefs_pref_name': 'last_payPeriod', 'tbl_Acct_Prefs_empID':
258}


If I use pymssql instead, it works. As I understand it, SA should be
using pymssql anyway, so I don't know why this is happening. I can
cast the unicode to a string, so it's not a big deal. However, I
thought someone might want to know that this is happening.

Oh, and I use autoload to load my Table() objects. I'm not sure if
that's significant or not though. I am also using a session.commit()
to get the error above.

I have upgraded to the 5.0beta3 too, but it gives the same error as
above. I am using Python 2.5.2 on Windows XP. Let me know if you
require additional information.

Thanks,

Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to