Martijn Moeling wrote:
>
> Hi,
>
> I have a python module where I am implementing several classes.
>
> When I do a "metadata.create_all(engine)"
>
> every time Mysql trows an exception (1064, PROGRAMMING ERROR), but on
> a different table, I think SQLAlchemy is behaving different every time
> I run the program.
>
>
> ie (one of the definitions failing):
>
> class Journal(Base):
>     __tablename__       = "CalendarJournals"
>     Id                  = Column(Integer(), primary_key=True,quote=True)
>     Attendees           = relation(Attendee, cascade="all")
>     Attachments         = relation(Attachment, cascade="all")
>     Catagories          = relation(Catagorie, cascade="all")     
>     Comments            = relation(Comment, cascade="all")
>     Contacts            = relation(Contact, cascade="all")
>     ExDates             = relation(ExDate, cascade="all")
>     ExRules             = relation(ExRule, cascade="all")
>     RDates              = relation(RDate, cascade="all")
>     Related             = relation(Relate, cascade="all")
>     RRules              = relation(RRule, cascade="all")
>     RStatusses          = relation(RStatus, cascade="all")
>     XProps              = relation(XProp, cascade="all")
>
>
>     Class               = Column(Unicode(20),quote=True)
>     Created             = Column(DateTime(),quote=True)
>     Description         = Column(UnicodeText(),quote=True)
>     DTStamp             = Column(DateTime(),quote=True)
>     DtStart             = Column(DateTime(),quote=True)
>     LastModified        = Column(DateTime(),quote=True)
>     RecurId             = Column(Unicode(),quote=True)
>     Sequence            = Column(Integer(),quote=True)    
>     Status              = Column(Unicode(),quote=True)
>     Summary             = Column(Unicode(),quote=True)
>     uid                 = Column(Unicode(),quote=True)
>     url                 = Column(Unicode(),quote=True)
>
> ProgrammingError: (ProgrammingError) (1064, "You have an error in your
> SQL syntax; check the manual that corresponds to your MySQL server
> version for the right syntax to use near ' \n\t`Sequence` INTEGER,
> \n\t`Status` VARCHAR, \n\t`Summary` VARCHAR, \n\t`uid` VARCHAR,' at
> line 9") '\nCREATE TABLE `CalendarJournals` (\n\t`Id` INTEGER NOT NULL
> AUTO_INCREMENT, \n\t`Class` VARCHAR(20), \n\t`Created` DATETIME,
> \n\t`Description` TEXT, \n\t`DTStamp` DATETIME, \n\t`DtStart`
> DATETIME, \n\t`LastModified` DATETIME, \n\t`RecurId` VARCHAR,
> \n\t`Sequence` INTEGER, \n\t`Status` VARCHAR, \n\t`Summary` VARCHAR,
> \n\t`uid` VARCHAR, \n\t`url` VARCHAR, \n\tPRIMARY KEY (`Id`)\n)\n\n' ()
>
> CREATE TABLE `CalendarJournals` (
> `Id` INTEGER NOT NULL AUTO_INCREMENT, 
> `Class` VARCHAR(20), 
> `Created` DATETIME, 
> `Description` TEXT, 
> `DTStamp` DATETIME, 
> `DtStart` DATETIME, 
> `LastModified` DATETIME, 
> `RecurId` VARCHAR, 
> `Sequence` INTEGER, 
> `Status` VARCHAR, 
> `Summary` VARCHAR, 
> `uid` VARCHAR, 
> `url` VARCHAR, 
> PRIMARY KEY (`Id`)
> )
>
> The Error: ERROR 1064 (42000) at line 3: You have an error in your SQL
> syntax; check the manual that corresponds to your MySQL server version
> for the right syntax to use near ' `Sequence` INTEGER, `Status`
> VARCHAR, `Summary` VARCHAR, `uid` VARCHAR, `url` V'
>
>
> Since the syntax seems to be correct and Sequence is Quoted with
> BackQuotes (`). I am puzzled what to do to fix this.

It is choking on your `RecurId` defintion, because MySQL requires all
VARCHAR columns to have a length specifier. You need to replace your
`Unicode()` column definitions with `Unicode(some_length)` or
`UnicodeText()`.

-Conor


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to