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.
on linux using the datetime classes works fine with t.date = datetime.date(2004,12,30) t.last_entry = datetime.time(23,55,56,345) but it does not work on windows. On win it seems to need the mx classes. So its really weird because on linux only datetime works and on windows only mx works :( On Windows I get the following stacktrace: Traceback (most recent call last): File "test2.py", line 33, in ? objectstore.flush() File "build\bdist.win32\egg\sqlalchemy\mapping\objectstore.py", line 260, in flush File "build\bdist.win32\egg\sqlalchemy\mapping\objectstore.py", line 81, in flush File "build\bdist.win32\egg\sqlalchemy\mapping\unitofwork.py", line 249, in flush File "build\bdist.win32\egg\sqlalchemy\mapping\unitofwork.py", line 374, in execute File "build\bdist.win32\egg\sqlalchemy\mapping\unitofwork.py", line 527, in execute File "build\bdist.win32\egg\sqlalchemy\mapping\mapper.py", line 616, in save_obj File "build\bdist.win32\egg\sqlalchemy\sql.py", line 473, in execute File "build\bdist.win32\egg\sqlalchemy\sql.py", line 378, in execute File "build\bdist.win32\egg\sqlalchemy\sql.py", line 355, in execute File "build\bdist.win32\egg\sqlalchemy\engine.py", line 645, in execute_compiled File "build\bdist.win32\egg\sqlalchemy\engine.py", line 542, in _process_defaults File "build\bdist.win32\egg\sqlalchemy\sql.py", line 271, in __getitem__ File "build\bdist.win32\egg\sqlalchemy\sql.py", line 692, in typeprocess File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 82, in convert_bind_param TypeError: argument 1 must be DateTime, not datetime.date
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?
yes I want to store only the time, so it was my intention to have a date and a time column ALex. On 5/21/06, Robin Munn <[EMAIL PROTECTED]> wrote:
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
------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users