Hmm... well this is a weird problem then. I ran the provided code, and got
the same result you did, with the DEFAULT & ON UPDATE missing. However, I
added a couple lines:
*from sqlalchemy.ext.declarative import declarative_base*
*from sqlalchemy import Table, CHAR, TIMESTAMP, TEXT, schema, Column*
*from uuid import uuid4 as uuid*
*
*
*Base = declarative_base()*
*class Foo(Base):*
* __tablename__ = 'foo'*
*
*
* #column definitions*
* id = Column(u'id', CHAR(length=36), default=uuid, primary_key=True,
nullable=False)*
* date_added = Column(u'dateAdded', TIMESTAMP(), nullable=False)*
* reason = Column(u'reason', TEXT())*
*
*
*from sqlalchemy.dialects import mysql*
*print schema.CreateTable(Foo.__table__).compile(dialect=mysql.dialect())*
*Base.metadata.bind = db.generate_engine()*
*Base.metadata.drop_all()*
*Base.metadata.create_all() *
The create table that was actually generated in the db is still:
*CREATE TABLE `foo` (*
* `id` char(36) NOT NULL,*
* `dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,*
* `reason` text,*
* PRIMARY KEY (`id`)*
*) ENGINE=InnoDB DEFAULT CHARSET=latin1;*
My generate_engine method is a little helper method that returns an engine
with the following params:
*create_engine('mysql://%s:%s@%s/%s' % (*
* config.get('database', 'user'),*
* urllib.quote_plus(config.get('database', 'pass')),*
* config.get('database', 'host'),*
* config.get('database', 'name')),*
* convert_unicode=True, pool_size=20, pool_recycle=60,*
* connect_args={'use_unicode': True, 'charset': 'utf8',
'compress': True})*
Am I unknowingly passing a default I shouldn't to SQLA that is causing the
generation of the table to add those defaults? Or is there an option in
MySQL that I unknowingly have turned on?
My versions:
Python 2.7
SQLA 0.7.*
MySQL version 5.5.11
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/leggvIPk0qgJ.
To post to this group, send email to [email protected].
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.