I also forgot to say what the new error I'm getting is. The traceback
is below. Some experimentation seems to suggest that the query is
getting truncated around the non-ascii char. I have a vague suspicion
that it might be related to UCS-2 padding with null chars and some
unix programs assuming that a null char is the end of the string. But
I don't really see how it would be affected by whether there was a non-
ascii char in the bind-params or not.
Traceback (most recent call last):
File "simple_thing.py", line 40, in <module>
session.commit()
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/session.py",
line 673, in commit
self.transaction.commit()
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/session.py",
line 378, in commit
self._prepare_impl()
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/session.py",
line 362, in _prepare_impl
self.session.flush()
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/session.py",
line 1358, in flush
self._flush(objects)
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/session.py",
line 1436, in _flush
flush_context.execute()
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/unitofwork.py",
line 261, in execute
UOWExecutor().execute(self, tasks)
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/unitofwork.py",
line 753, in execute
self.execute_save_steps(trans, task)
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/unitofwork.py",
line 768, in execute_save_steps
self.save_objects(trans, task)
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/unitofwork.py",
line 759, in save_objects
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
File "/home/singletoned/src/sa06/lib/sqlalchemy/orm/mapper.py",
line 1393, in _save_obj
c = connection.execute(statement.values(value_params), params)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/base.py",
line 984, in execute
return Connection.executors[c](self, object, multiparams, params)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/base.py",
line 1047, in _execute_clauseelement
return self.__execute_context(context)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/base.py",
line 1069, in __execute_context
self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/base.py",
line 1126, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor,
context)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/base.py",
line 1124, in _cursor_execute
self.dialect.do_execute(cursor, statement, parameters,
context=context)
File "/home/singletoned/src/sa06/lib/sqlalchemy/engine/default.py",
line 172, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000]
[FreeTDS][SQL Server]The incoming tabular data stream (TDS) protocol
stream is incorrect. The stream ended unexpectedly. (4002)
(SQLExecDirectW)') 'INSERT INTO [ThingTable] (id, text_field) VALUES
(?, ?)' ['flib', 'test\xc2\xa3']
On 29 Jul 2009, at 18:30, Ed Singleton wrote:
> Stupidly forgot to attach the files.
>
> <simple_thing.py> <complex_thing.py>
>
> On 29 Jul 2009, at 18:27, Ed Singleton wrote:
>
>> On 25 Jul 2009, at 03:17, mtrier wrote:
>>> On Jul 23, 8:30 am, Ed Singleton <[email protected]> wrote:
>>>> I've managed to get SA (0.6 branch) and pyodbc connecting to
>>>> anMSSQL
>>>> db on Mac OS X, but I've recently been trying to get it working on
>>>> linux (Debian Lenny) and have been hitting some problems.
>>>>
>>>> It's definitely working to some degree. Adding "TDS_Version =
>>>> 8.0" to
>>>> my odbc.ini fixed some unicode problems, and so now simple pyodbc
>>>> stuff seems to work. Querying seems to be fine, but sometimes
>>>> adding
>>>> lots of data using the orm fails with the message: DBAPIError:
>>>> (Error)
>>>> ('HY000', 'The driver did not supply an error!')
>>>>
>>>> The same error occurs in both SA 0.5.5 and SA 0.6
>>>>
>>>> I'm going to try a few more things to narrow down a bit more
>>>> where the
>>>> problem is, but if any has any ideas of what it could be or how I
>>>> could debug it, I'd be very grateful.
>>>
>>> Any luck on this? I'm using both with OSX and Ubuntu without
>>> differences in behavior. Do you have an isolated test case that
>>> duplicates this behavior?
>>
>> I don't yet have an isolated test case that causes the same error,
>> but I do now have an isolated test case that doesn't work, and that
>> I'd like to get working.
>>
>> There's two attached files with reasonably simple cases in. The
>> first, simple_thing.py contains a single example. I've tried
>> tweaking various things in it to various effect.
>>
>> The second, complex_thing.py, contains a test generator that
>> generates 64 tests (for now), testing all the different
>> combinations of things that might affect the success of the test.
>> This one also clearly shows the difference between Mac and Linux on
>> my setup, as on the Mac several of the 'non_ascii£' tests pass.
>>
>> Note that it isn't expected for all the tests to pass. Some of the
>> combinations are wrong. It just shows what works and what doesn't.
>>
>> On both the Mac and Linux, my setup is happy with some unicode
>> queries and/or params. Sometimes it will raise a warning if you
>> are inserting unicode into a non-unicode field, and sometimes it
>> will fail for the same reason.
>>
>> What I'm trying to achieve is:
>>
>> 1) Ability to insert non-ascii chars into the db on Linux
>> 2) The above but for all column types (varchar, text, nvarchar,
>> ntext)
>>
>> Absolutely any ideas will be appreciated. I'm not sure what to try
>> next. For now I'm going to document how I set up Linux.
>>
>> Thanks
>>
>> Ed
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---