On 5/21/06, Alex Greif <[EMAIL PROTECTED]> wrote:
The following code works on windows but crashes on linux. It uses SA 0.1.7.
I am not sure whether the first import line makes problems, but as I
said it works fine on windows. Both running Python-2.4.2

any help is appreciated

Alex.


#######  code  ###########

import mx.DateTime.DateTime as mxDateTime
from sqlalchemy import *

e = create_engine("postgres://database=test", echo=True)

test = Table("test", e,
               Column("id", Integer, primary_key=True),
               Column("date", Date),
               Column("last_entry", Time),
             )
class Test(object):
      pass
Test.mapper = mapper(Test, test)

try:
  test.drop()
except:
  pass
test.create()

t = Test()
t.date = mxDateTime(2004,12,30)
t.last_entry = mxDateTime(2004,12,31,23,55,56.345)

objectstore.flush()

I have three questions about your code.

First, does it work when using the date, time and datetime objects
from Python's builtin datetime module? As I understand it, mx.DateTime
and the Python datetime module do not have the same API, and I believe
SQLAlchemy is designed for the Python datetime module rather than for
mx.DateTime.

Second, if the Python datetime module works, is there a particular
reason why you need to use mx.DateTime? It would probably be simpler
to use the builtin module, since that's one less module dependency you
have to install when you deploy your application.

Third, I notice you're using a Time data type for the last_entry
column -- which only stores time-of-day. Don't you want a DateTime
data type for that column instead?

Let me know if changing last_entry to a DateTime type, and/or using
Python datetime objects instead of mx.DateTime, solves your problem.

--
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014
Rȧ�:&q�[���y�hv����^y�h��i��py����z�r���!���n}�h�ꮉ�%����ފ{^���y�^r薈2����쨺��m欉�ã
 塧HŞm*az����bq�b�t�����]5m�v����!xg��x��m���zV���ږF�����\�

Reply via email to