[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-07-01 Thread Gloria W

Got it, thanks for your help.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-30 Thread Gloria W

I thought this was a scope problem, but it seems to be even bigger.
This is the error I get:
OperationalError: (OperationalError) (1067, Invalid default value for
'date_created') u'\nCREATE TABLE fu_op_requests (\n
\tfu_op_requests_id INTEGER NOT NULL AUTO_INCREMENT, \n\tname
VARCHAR(50), \n\trequested_items VARCHAR(300), \n\tamount_donated
FLOAT(4), \n\tcomments VARCHAR(300), \n\tdate_created DATETIME DEFAULT
now() NOT NULL, \n\tPRIMARY KEY (fu_op_requests_id)\n)\n\n' {}

Wow, how could it be generating a DATETIME DEFAULT now() raw command
from this syntax?

from sqlalchemy.databases import mysql
purchases_table = sqlalchemy.Table('fu_op_purchases',
metadata,
sqlalchemy.Column('fu_op_purchases_id',
sqlalchemy.Integer, primary_key=True),
sqlalchemy.Column('name', sqlalchemy.String(50)),
sqlalchemy.Column('purchased_item',
sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('price', sqlalchemy.Float(4)),
sqlalchemy.Column('comments', sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('date_created', mysql.MSTimeStamp,
sqlalchemy.PassiveDefault(sqlalchemy.text(CURRENT_TIMESTAMP)),
nullable=False))

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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-30 Thread Michael Bayer

running this script:

import sqlalchemy
from sqlalchemy.databases import mysql

engine = sqlalchemy.create_engine('mysql://scott:[EMAIL PROTECTED]/ 
test', echo=True)
metadata = sqlalchemy.MetaData(engine)

purchases_table = sqlalchemy.Table('fu_op_purchases',metadata,
sqlalchemy.Column('fu_op_purchases_id',sqlalchemy.Integer,  
primary_key=True),
sqlalchemy.Column('name', sqlalchemy.String(50)),
sqlalchemy.Column('purchased_item',sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('price', sqlalchemy.Float(4)),
sqlalchemy.Column('comments', sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('date_created',  
mysql 
.MSTimeStamp 
,sqlalchemy 
.PassiveDefault(sqlalchemy.text(CURRENT_TIMESTAMP)),nullable=False))

purchases_table.create()

produces this output:

CREATE TABLE fu_op_purchases (
fu_op_purchases_id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(50),
purchased_item VARCHAR(300),
price FLOAT(4),
comments VARCHAR(300),
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (fu_op_purchases_id)
)



On Jun 30, 2008, at 5:51 PM, Gloria W wrote:


 I thought this was a scope problem, but it seems to be even bigger.
 This is the error I get:
 OperationalError: (OperationalError) (1067, Invalid default value for
 'date_created') u'\nCREATE TABLE fu_op_requests (\n
 \tfu_op_requests_id INTEGER NOT NULL AUTO_INCREMENT, \n\tname
 VARCHAR(50), \n\trequested_items VARCHAR(300), \n\tamount_donated
 FLOAT(4), \n\tcomments VARCHAR(300), \n\tdate_created DATETIME DEFAULT
 now() NOT NULL, \n\tPRIMARY KEY (fu_op_requests_id)\n)\n\n' {}

 Wow, how could it be generating a DATETIME DEFAULT now() raw command
 from this syntax?

from sqlalchemy.databases import mysql
purchases_table = sqlalchemy.Table('fu_op_purchases',
 metadata,
sqlalchemy.Column('fu_op_purchases_id',
 sqlalchemy.Integer, primary_key=True),
sqlalchemy.Column('name', sqlalchemy.String(50)),
sqlalchemy.Column('purchased_item',
 sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('price', sqlalchemy.Float(4)),
sqlalchemy.Column('comments', sqlalchemy.VARCHAR(300)),
sqlalchemy.Column('date_created', mysql.MSTimeStamp,
 sqlalchemy.PassiveDefault(sqlalchemy.text(CURRENT_TIMESTAMP)),
 nullable=False))

 


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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread Michael Bayer

to my knowledge MySQL doesn't support DEFAULT on date/time columns.
You can work with the MySQL database directly a little bit to confirm  
this.


On Jun 28, 2008, at 3:18 PM, 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?

 Thank you in advance,
 Gloria

 


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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland

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)

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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland

jason kirtland wrote:
 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)

err, mysql.MSTimeStamp


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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread Gloria W

This gives me an error:

sqlalchemy.Column('date_created', mysql.MSTimeStamp,
sqlalchemy.PassiveDefault(text(CURRENT_TIMESTAMP)),
nullable=False))
NameError: global name 'text' is not defined

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



[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland

Gloria W wrote:
 This gives me an error:
 
 sqlalchemy.Column('date_created', mysql.MSTimeStamp,
 sqlalchemy.PassiveDefault(text(CURRENT_TIMESTAMP)),
 nullable=False))
 NameError: global name 'text' is not defined

from sqlalchemy import text


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