Not sure what you asking. You are welcome to post sqlachemy code.
On Friday, 17 August 2012 15:31:30 UTC-5, Larry Wapnitsky wrote:
>
> also, do you think I might be better off doing this in MongoDB rather
> than MySQL/SQLAlchemy?
>
> On 8/17/2012 3:41 PM, Massimo Di Pierro wrote:
>
> It depends on context. Web2py DAL is closer to SQL than on ORM. Assuming
>
> db.define_table('person',Field('name'),Field('email'))
>
> you have two options:
>
> 1)
>
> db.define_table('message',Field('body'),Field('recipients','list:reference
> person'))
>
> for row in db(db.message).select(): # one select
> for recipient in row.recipents:
> print recipient.name # one select per recipient to get name (lazy)
>
>
> 2)
>
> db.define_table('message',Field('body'))
>
> db.define_table('recipient',Field('message',db.message),Field('person',db.person))
>
> for message in db(db.message).select():
> for recipient in message.recipient.select() # one select/message
> print recipient.person.name # one select/recipient
>
> or with a single select using joins:
>
> for row in db(db.message.id==db.recipient.message)(db.recipient.person==
> person.id).select()
> print row.message.body, row.person.id
>
>
>
>
> On Friday, 17 August 2012 11:01:34 UTC-5, Larry Wapnitsky wrote:
>>
>> OK. I"m getting close, but I"m stuck on the following SQLAlchemy code
>> conversion:
>>
>> recipients = relationship( 'Recipient',
>> secondary = mr_link,
>> backref = 'message',
>> lazy = 'dynamic' )
>>
>>
>> attachments = relationship( 'Attachment',
>> secondary = ma_link,
>> backref = 'message',
>> lazy = 'dynamic' )
>>
>>
>> I don't see how to adapt this in the manual.
>>
>> TIA,
>> Larry
>>
>> On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote:
>>>
>>> Thanks, Massimo. I'll give this a read and see if I can adapt it
>>> properly.
>>>
>>> As usual, your hard work is greatly appreciated.
>>>
>>> On 8/15/2012 6:34 PM, Massimo Di Pierro wrote:
>>>
>>> I meant this:
>>>
>>> http://web2py.com/AlterEgo/default/show/189
>>>
>>>
>>> On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote:
>>>>
>>>> I have a project in which I've just written the database functions
>>>> using SQLAlchemy. It was much simpler than my original, hand-written SQL
>>>> queries, especially once I got the hang of creating "relationships" with
>>>> SA's ORM.
>>>>
>>>> Now, I would like to create a front-end for this using web2py, but,
>>>> from experience, I know the DAL and SA's ORM are very different.
>>>>
>>>> What's the group's view on the best way to integrate my two projects?
>>>>
>>> --
>>>
>>>
>>>
>>>
>>>
>>> --
>
>
>
>
>
>
--