Either of these works for the individual queries, but when combined in the
union() or union_all() the result is still that the literal from the first
query is used on all result rows
q1 = session.query(A.data.label('somedata'), literal('A').label('source'))
q2 =
Dnia 2009-08-27, czw o godzinie 10:51 -0400, Michael Bayer pisze:
you can also set up primaryjoin using the actual table
columns (i.e. PhysObject.locationId == Location.__table__.c.id).
Thanks, that worked really well :). Now i am stuck with something else
in this subject:
Hello,
I read http://www.sqlalchemy.org/trac/wiki/06Migration and did not see a
mention of any changes to type mapping or casting.
I am currently using 0.5.5. While developing an application I found that
generating tables from a declarative model resulted in undesirable /
incorrect column
Teemu Yli-Elsilä wrote:
Hello,
I read http://www.sqlalchemy.org/trac/wiki/06Migration and did not see a
mention of any changes to type mapping or casting.
I am currently using 0.5.5. While developing an application I found that
generating tables from a declarative model resulted in
What is correct way to join two subqueries? The example is somewhat
contrived, but illustrates the problem.
SQL might look like this
SELECT x.blah, y.blah
FROM (SELECT id, data AS blah FROM a) AS x
JOIN (SELECT id, data AS blah FROM b) AS y
ON x.id = y.id
Mapped classes are:
class A(Base):
Mike Conley wrote:
What is correct way to join two subqueries? The example is somewhat
contrived, but illustrates the problem.
SQL might look like this
SELECT x.blah, y.blah
FROM (SELECT id, data AS blah FROM a) AS x
JOIN (SELECT id, data AS blah FROM b) AS y
ON x.id = y.id
Mapped
I have a small project I am trying to finish and I ran into a hiccup.
I saw the sqlachemy.sql.func object and decided to try to use it. Here
is the code to get us on the same page.
userPassword = 'thisisasalt';
insertDictionary = [{
'user_name': user_name,
'user_pwd':
Mike,
Thanks again for your posts. What about something like:
q1 = DBSession.query(P1.id, P1.user_id, P1.type, P1.title, P1.body,
P1.created, P1.updated, User.name).filter(P1.user_id==User.id)
q2 = DBSession.query(P2.id, P2.user_id, 'P2', P2.title, P2.body,
P2.created, P2.updated,
Eric Naeseth wrote:
SQLAlchemy seems to have an issue reflecting MySQL tables that have
foreign keys when the table being reflected is not in the database
specified in the connection string.
Let's say I'm working on an app to manage a database named library,
but that I also need access to
Tefnet Developers wrote:
Dnia 2009-08-27, czw o godzinie 10:51 -0400, Michael Bayer pisze:
you can also set up primaryjoin using the actual table
columns (i.e. PhysObject.locationId == Location.__table__.c.id).
Thanks, that worked really well :). Now i am stuck with something else
in
It works and will probably be OK. Using this style (query for user multiple
times) in a really big database could lead to a performance problem
depending on how the underlying database engine constructs a query plan. Try
it and see how it goes.
--
Mike Conley
On Fri, Aug 28, 2009 at 2:22 PM,
Mike Conley wrote:
Either of these works for the individual queries, but when combined in the
union() or union_all() the result is still that the literal from the first
query is used on all result rows
q1 = session.query(A.data.label('somedata'), literal('A').label('source'))
q2 =
I guess I should restate the question.
I have two tables:
class Foo(Base):
__tablename__ = 'foo'
id = Column(Integer, primary_key=True)
mdata = Column(UnicodeText)
bar = relation(Bar)
def __repr__(self):
return Foo(%r) % self.mdata
class Bar(Base):
Michael Bayer wrote:
Eric Naeseth wrote:
SQLAlchemy seems to have an issue reflecting MySQL tables that have
foreign keys when the table being reflected is not in the database
specified in the connection string.
Let's say I'm working on an app to manage a database named library,
but
Dnia 2009-08-28, Pt o godzinie 10:51 -0400, Michael Bayer pisze:
Tefnet Developers wrote:
Dnia 2009-08-27, czw o godzinie 10:51 -0400, Michael Bayer pisze:
you can also set up primaryjoin using the actual table
columns (i.e. PhysObject.locationId == Location.__table__.c.id).
Hi,
I created ORM classes and can't find out a way to make an
UniqueConstraint for two columns. Do we have an example elsewhere?
When I used UniqueConstraint from sqlachemy.schema inside of ORM class
it does nothing, so it's not defined in a table. In particular here is
my class
class
Tomasz Jezierski - Tefnet wrote:
Awkward column_property is because of exception you'll get if try to set
Column without column_proprerty around it:
---
sqlalchemy.exc.ArgumentError: Column 'PhysObject.locationId' is not
represented in mapper's table. Use the `column_property()` function
I can't seem to figure out how to tell sqlalchemy to do something
like :
UPDATE Foo
SET turnover = 1
WHERE EXPLANATION NOT IN(SELECT Reason FROM mbsIsTurnoverXLAT where
Datasource ='blah' and Isturnover=0)
AND DATASOURCE = 'blah'
The not in clause is the part that's tripping me up. I'm not
Tomasz Jezierski - Tefnet wrote:
Awkward column_property is because of exception you'll get if try to set
Column without column_proprerty around it:
---
sqlalchemy.exc.ArgumentError: Column 'PhysObject.locationId' is not
represented in mapper's table. Use the `column_property()` function to
Tomasz Jezierski - Tefnet wrote:
---
sqlalchemy.exc.ArgumentError: Column 'PhysObject.locationId' is not
represented in mapper's table. Use the `column_property()` function to
force this column to be mapped as a read-only attribute.
ticket # 1523 has a patch that allows this approach to
Constraints are defined in __table_args__ try:
__table_args__ = (
UniqueConstraint('api_id', 'daskey_id', name='uix_1'),
{'mysql_engine':'InnoDB'})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Here is what I am doing now (even forgetting the limit):
-
username = u'hal'
subq = SES.query(Bar).filter(Bar.username == username).\
subquery()
valias = aliased(Bar, subq)
q = SES.query(Foo, valias).order_by(Foo.mdata).\
outerjoin(Foo.bar, valias)
recs = q.all()
I've seen similar discussions here, but it's been a while so perhaps
things have changed.
class Foo(Base):
__tablename__ = 'foo'
type = Column(Integer)
__mapper_args__ = {'polymorphic_on': type}
...
class BarFoo(Foo):
__mapper_args__ = {'polymorphic_identity': 1}
bar_id =
Hi all,
I have a pretty basic question about autoflush that I could not find
an answer to. By default, in sessionmaker, this is set to true.
However, I have this basic scenario where my transaction involves
inserting objects into session and querying for some others:
add(o1)
query(SomeObject)
Okay. I believe this is my mistake. I just wrote a simple test program
and saw that the other threads should not see o1 or o2 until commit
since I am using scoped_session. I guess there is another reason for
the behavior I am seeing.
On Aug 28, 10:05 pm, gizli mehm...@gmail.com wrote:
Hi all,
25 matches
Mail list logo