I've got a fairly simple database made with django and accessed via sqlsoup.
(finally got some time to take more of a look at the tutorial, which helped a 
little :)

The two tables are

devmap_device
   id
  device_name
  manufacturer_id

devmap_manufacturer
  id
  manufacturer_name

I tried to make a join to retrieve a device/manufacturer...


>>> from db import devmap_device, devmap_manufacturer
>>> 
>>> e = create_engine('postgres://user:passw...@127.0.0.1/xxxx')
>>> db = SqlSoup(MetaData(e))
>>> 
>>> db.devmap_device.join(db.devmap_manufacturer, 
>>> db.devmap_device.manufacturer_id == db.devmap_manufacturer.id).first()
>>> 

### At this point it says:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <lambda>
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\util.py", 
line 212, in go
    return fn(*args, **kw)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\orm\query.py",
 line 873, in join
    return self.__join(props, outerjoin=False, create_aliases=aliased, 
from_joinpoint=from_joinpoint)
  File "<string>", line 1, in <lambda>
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\orm\query.py",
 line 52, in generate
    fn(self, *args[1:], **kw)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\orm\query.py",
 line 1071, in __join
    clause = orm_join(clause, right_entity, onclause, isouter=outerjoin, 
join_to_left=join_to_left)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\orm\util.py",
 line 432, in join
    return _ORMJoin(left, right, onclause, isouter, join_to_left)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\orm\util.py",
 line 409, in __init__
    expression.Join.__init__(self, left, right, onclause, isouter)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\sql\expression.py",
 line 2479, in __init__
    self.right = _selectable(right).self_group()
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\sql\expression.py",
 line 968, in _selectable

    raise exc.ArgumentError("Object %r is not a Selectable and does not 
implement `__selectable__()`" % element)
sqlalchemy.exc.ArgumentError: Object 
<sqlalchemy.sql.expression._BinaryExpression object at 0x00FAB4B0> is not a 
Selecta
ble and does not implement `__selectable__()`

### 

Also, if I try
>>> db.with_labels(db.devmap_manufacturer)

It says:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\ext\sqlsoup.py",
 line 534, in with_labels
    return 
self.map(expression._selectable(item).select(use_labels=True).alias('foo'))
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\ext\sqlsoup.py",
 line 528, in map
    t = class_for_table(selectable, **kwargs)
  File 
"c:\python25\lib\site-packages\SQLAlchemy-0.5.2-py2.5.egg\sqlalchemy\ext\sqlsoup.py",
 line 448, in class_for_tabl
e
    engine_encoding = selectable.metadata.bind.dialect.encoding
AttributeError: 'Alias' object has no attribute 'metadata'


...which seems strange as 
>>> db.with_labels(db.devmap_device)

works fine !



      

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to