Hello

I am seeing an error when trying to insert a row with a date field
into an SQLite database. The error is the same as the problem that has
been seen with Decimals on postgres but presumably it's a different
issue. I have upgraded my pysqlite to 3.3.17 but that didn't help.

Below is the full error and a minimal repro scenario.

The problem goes away if you reorder the columns in the table creation
code to put the date column last (sadly this doesn't fix the problem
in my real code...). I have other tables with date columns that work
without any problem. I noticed in the log for inserting rows into
those other tables that the date value appears in the SQL as something
like '2007-06-01' rather than '(datetime.date(2007, 6, 1),)' as in the
error message below. That may be relevant or it may be an artefact of
the way the log message is created as opposed to the exception string.

I'm running Python 2.5 on Windows with SQLAlchemy 0.3.7.

Any ideas what the problem might be?

Thanks
Ben

---------------------------------

Traceback (most recent call last):
  File "C:\cygwin\home\barwork\test.py", line 20, in <module>
    session.flush()
  File "build\bdist.win32\egg\sqlalchemy\orm\session.py", line 302, in
flush
  File "build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py", line 219,
in flush
  File "build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py", line 409,
in execute
  File "build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py", line
1027, in execute
  File "build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py", line
1041, in execute_save_steps
  File "build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py", line
1032, in save_objects
  File "build\bdist.win32\egg\sqlalchemy\orm\mapper.py", line 1182, in
save_obj
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 509, in
execute
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 549, in
execute_clauseelement
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 560, in
execute_compiled
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 573, in
_execute_raw
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 591, in
_execute
sqlalchemy.exceptions.SQLError: (InterfaceError) Error binding
parameter 1 - probably unsupported type. u'INSERT INTO things (date,
value) VALUES (?,?)' ['(datetime.date(2007, 6, 1),)', ('asdf',)]

from sqlalchemy import *
from datetime import date

class Thing(object):
    def __init__(self, date, value):
        self.date = date,
        self.value = value,

thing_table = Table('things',
                    Column('id', Integer, primary_key=True),
                    Column('date', Date),
                    Column('value', String(10)))
mapper(Thing, thing_table)

global_connect('sqlite://')
default_metadata.create_all()

session = create_session()
session.save(Thing(date.today(), 'asdf'))
session.flush()


--~--~---------~--~----~------------~-------~--~----~
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