On Thu, Feb 12, 2009 at 12:10 PM, Roger Demetrescu
<[email protected]> wrote:
>
> On Thu, Feb 12, 2009 at 14:36, Lukasz Szybalski <[email protected]> wrote:
>>
>> On Thu, Feb 12, 2009 at 11:12 AM, jorge.vargas <[email protected]>
>> wrote:
>>>
>>> On Thu, Feb 12, 2009 at 4:20 AM, Christoph Zwerschke <[email protected]> wrote:
>>>>
>>>> Lukasz Szybalski schrieb:
>>>>> sa_table def, python class, mapper seem like a natural approach. I'm
>>>>> not sure what declarative_base does for me that is different?
>>>>'
>>> please see
>>> http://www.sqlalchemy.org/docs/05/ormtutorial.html#creating-table-class-and-mapper-all-at-once-declaratively
>>
>>
>> Looks ok.
>>
>> So now, how do I autoload using this declerative_base?
>>
>> In the classic example when you define a table you say:
>> sqlalchemy.Table(name, metadata, autoload=True)
>>
>> now with declarative approach you do?
>
>
> http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#table-configuration
>
>
> I guess this would also work:
>
> mytable = Table(name, metadata, autoload=True)
>
> class MyClass(MyDeclarativeBase):
> __table__ = mytable
>
How do I drop a table in a controller without recreating engine to
bind the delete command?
mytable.__table__.drop(bind=DBSession.bind)
How do I delete from xyz?
DBSession.delete(mytable)
gives error:
Traceback (most recent call last):
.....
raise exc.UnmappedInstanceError(instance)
UnmappedInstanceError: Class
'sqlalchemy.ext.declarative.DeclarativeMeta' is not mapped; was a
class (myapp.model.myfile.mytable) supplied where an instance was
required?
I can do DBSession.query(mytable).delete() but that executes extra
select statement...??
Thanks,
Lucas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---