Hello Max,

AFAIR, I've had similar problems latelty when having a table with 
composite primary keys and running SQLite. I think Mike told me SQLite 
didn't support that. I'm no SQLite user, but I had this problem when I 
had to make a portable test case with SQLite in memory. If this can put 
you on track.

Regards,
-- 
Alexandre CONRAD


Max Ischenko wrote:
> Hello,
> 
> I'm struggling with a simple one to many relation, pls help!
> 
> 
> active_meetup = MeetupEvent(...)
> reg = MeetupRegistration(meeting=active_meetup)
> 
> db.save(reg)
> 
> <class 'sqlalchemy.exceptions.OperationalError'>: (OperationalError) 
> (1048, "Column 'meeting_id' cannot be null") u'INSERT INTO 
> dou_meetup_registrants (meeting_id, name, email, phone) VALUES (%s, %s, 
> %s, %s)' [None, u'1.0', u'[EMAIL PROTECTED] 
> <mailto:u'[EMAIL PROTECTED]>', u'+38 063 2061046']
> 
> Obviously SA somehow can't find meeting_id even thou reg.meeting is OK.
> 
> Here is my mapping code:
> 
>     dou_meetupregs_tbl = Table('dou_meetup_registrants', meta,
>             autoload=True)
>     dou_meetups_tbl = Table('dou_meetups', meta, autoload=True)
>     mapper(MeetupEvent, dou_meetups_tbl, properties={
>             'registrants':relation(MeetupRegistration, backref='meetup'),
>         })
>     mapper(MeetupRegistration, dou_meetupregs_tbl, properties={
>         })
> 
> And classes (just in case):
> 
> class MeetupEvent(object):
>     regcount = property(fget=lambda self: len(self.registrants))
> 
>     def __repr__(self):
>         return "<MeetupEvent %s %r>" % (self.id <http://self.id>, self.url)
> 
> class MeetupRegistration(object):
>     def __init__(self, meeting, name=None, email=None, phone=None):
>         if not meeting:
>             raise ValueError("Meeting event not set")
>         if not email:
>             raise ValueError("Email is required")
>         self.meeting = meeting
>         self.name <http://self.name> = name
>         self.email = email
>         self.phone = phone
> 
>     def __repr__(self):
>         return "<MeetupRegistration %s (%s,%s)>" % (self.id 
> <http://self.id>, self.meeting.id <http://self.meeting.id>, self.email)
> 
> -- 
> Max
> http://maxischenko.in.ua // http://www.linkedin.com/in/maksim
> > 



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

Reply via email to