Then your view is not *well defined*.  Your database doesn't know what 
the primary key is on the view, so SQLSoup won't be able to determine 
this either.  You are adding it in the ORM layer.

If your database supports primary and foreign keys on views then you can 
set these up and SQLSoup will work on the view.  Oracle supports this, I 
don't know about others, I think there was a thread about constraints 
and views a couple of weeks ago.


John

jose wrote:
> Lee McFadden wrote:
>
>   
>> On 11/30/06, jose <[EMAIL PROTECTED]> wrote:
>>  
>>
>>     
>>> John Lavoie wrote:
>>>
>>>    
>>>
>>>       
>>>> sqlsoup is for connecting to databases where your structure is already
>>>> defined.  If you are connecting to a legacy database that you cannot
>>>> modify, sqlsoup will automatically read the database and generate all of
>>>> your ORM classes without any additional configuration.
>>>>
>>>> Of course, this assumes that you have a well defined database that has
>>>> all primary and foreign keys defined.
>>>>
>>>>
>>>>
>>>>      
>>>>
>>>>         
>>> sqlalchemy already does it for me with the command:
>>>
>>> mytable = Table(name, database.metadata, autoload=True)
>>>
>>>    
>>>
>>>       
>> No, you're missing the point.  There would be no need to define the
>> table like that, you'd just do:
>>
>> db = SqlSoup(metadata)
>>
>> Then you can access all your tables via db.<tablename> as you would do
>> with your normal table definitions.  If you have a very large amount
>> of *well defined* tables in your database then SqlSoup may save you a
>> lot of time and typing.
>>
>>
>>  
>>
>>     
> This is very interesting.
>
> What about views?
> Views have no primary keys.
> I have a view defined as:
>
> view['name'] = Table('name', database.metadata, autoload=True)
>
> class WassignedPerms(DomainObject):
>     def __str__(self):
>         return self.description or repr(self)
>
> assign_mapper(context, WassignedPerms, view['name'],
>      primary_key = [ view['name'].c.group_id, view['name'].c.permission_id ]
>      )
>
> I tried to define it using sqlsoup as:
> ----------
> class WassignedPerms(DomainObject):
>     def __str__(self):
>         return self.description or repr(self)
>
> assign_mapper(context, WassignedPerms, db.name._table,
>      primary_key = [ db.name.c.group_id, db.name.c.permission_id ]
>      )
>
> here error message:
>     sqlalchemy.ext.sqlsoup.PKNotFoundError: table 'name' does not have a 
> primary key defined
>
>
> >
>
>   

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

Reply via email to