10 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: MySQL 5.0 DateTime i...
FromSent OnAttachments
Gloria W28 Jun 2008 12:12 
Gloria W28 Jun 2008 12:17 
Michael Bayer29 Jun 2008 09:02 
jason kirtland29 Jun 2008 10:10 
jason kirtland29 Jun 2008 10:12 
Gloria W29 Jun 2008 17:17 
jason kirtland29 Jun 2008 17:52 
Gloria W30 Jun 2008 14:51 
Michael Bayer30 Jun 2008 15:19 
Gloria W01 Jul 2008 08:36 
Subject:[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.
From:jason kirtland (je@discorporate.us)
Date:06/29/2008 10:10:04 AM
List:com.googlegroups.sqlalchemy

Gloria W wrote:

Hi All,

Looking back in these posts, I tried several older variants of MySQL datetime column initialization discussed here, and they're not working.

This works in Postgresql:

sqlalchemy.Column('date_created', sqlalchemy.DateTime, sqlalchemy.PassiveDefault(sqlalchemy.sql.func.now()), nullable=False)

But the MySQL equivalent fails:

sqlalchemy.Column('date_created', sqlalchemy.DateTime, sqlalchemy.PassiveDefault(text("CURRENT_TIMESTAMP")), nullable=False)

What is the valid syntax? Is it failing for other reasons?

The MySQL TIMESTAMP type is required for that default:

from sqlalchemy.databases import mysql sqlalchemy.Column('date_created', mysql.MSDateTime, sqlalchemy.PassiveDefault(text("CURRENT_TIMESTAMP")), nullable=False)