[sqlalchemy] flask + sqlalchemy +postgresql how can i check out the data from my db???

2014-06-30 Thread 'Frank Liou' via sqlalchemy
this is my code . my question is how can i check out the data from my db. i have try query=session.query(Friend) but i think that might be wrong so..what place i have to add the code query=seesion.query(frined)??? p.s. i just the rookie this is my database id | name

Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-06-30 Thread Simon King
I'm not sure I understand your application. Are you saying that you have Person instances that stay in memory for longer than a single web request? Simon On Sun, Jun 29, 2014 at 11:54 AM, Bao Niu niuba...@gmail.com wrote: Hi Mike, Thanks for your reply. In my case, the full_name attribute is a

Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-06-30 Thread Bao Niu
Hi Simon, Sorry for the poor explanation in my previous post. Let me try to clarify this using a flow here: --- 1st_web_request comes in to tell the server which person instances are to be interested. because it involves

Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-06-30 Thread Simon King
What you are suggesting is definitely not what I think of as the traditional pattern for a web application (but I don't know exactly what you are trying to do, so perhaps you have good reasons for doing things this way). In the web applications that I write, there is no real state on the server

Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-06-30 Thread Bao Niu
Thanks Simon. I think my train of thought isn't quite clear at this point. Sorry for this, I appreciate your comment and you are right I think I need to work on my understanding of two different session concept, it's a bit complex. On Jun 30, 2014 4:12 AM, Simon King si...@simonking.org.uk wrote:

[sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread univerio
Consider the following configuration: class Employee(Base): __tablename__ = employee id = Column(Integer, primary_key=True) type = Column(String(100)) cars = relationship(Car) __mapper_args__ = { polymorphic_on: type, } class Car(Base): __tablename__

[sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Phillip Aquilina
Using postgresql, I have a JSON type column. My understanding from their docs was that only jsonb columns could have an index created on them (a feature of postgresql 9.4) but then I found an SO answer http://stackoverflow.com/questions/17807030/how-to-create-index-on-json-field-in-postgres-9-3

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 6:01 PM, univerio wrote: Consider the following configuration: class Employee(Base): __tablename__ = employee id = Column(Integer, primary_key=True) type = Column(String(100)) cars = relationship(Car) __mapper_args__ = {

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 7:03 PM, Mike Bayer wrote: there's a little bit of a glitch here, however in any case, the ORDER BY would be from E.Engineer.specialty. The glitch is that the subq load at the moment seems to need an additional hint as to what its selecting from:

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Jack Zhou
Thanks for the quick response, Mike! On Mon, Jun 30, 2014 at 4:26 PM, Mike Bayer mike...@zzzcomputing.com wrote: On 6/30/14, 7:03 PM, Mike Bayer wrote: there's a little bit of a glitch here, however in any case, the ORDER BY would be from E.Engineer.specialty. The glitch is that the

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 7:29 PM, Jack Zhou wrote: Thanks for the quick response, Mike! that's all fixed in master / rel_1_0 and rel_0_9 branches (as you know I like to fix these deep polymorphic loader issues ASAP) On Mon, Jun 30, 2014 at 4:26 PM, Mike Bayer mike...@zzzcomputing.com

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
SQLAlchemy's API allows CREATE INDEX via the Index construct: http://docs.sqlalchemy.org/en/rel_0_9/core/constraints.html?highlight=index#indexes On 6/30/14, 6:21 PM, Phillip Aquilina wrote: Using postgresql, I have a JSON type column. My understanding from their docs was that only jsonb

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Phillip Aquilina
Thanks for replying. I've read through that doc and I still don't see how that addresses my question. Is there somewhere in there that describes how to create an index on a json field? It seems like to me it's simple to create an index on a column but this would be creating an index on nested

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
I'm not familiar with any other style of index for this column type. If you can show me at http://www.postgresql.org/docs/9.4/static/datatype-json.html or wherever what specific DDL you're looking for, you can simply emit it using engine.execute(ddl). On 6/30/14, 11:02 PM, Phillip Aquilina

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
per the SO answer, you're looking for CREATE INDEX ON publishers((info-'name'));. Either you can emit this directly as a string, or use Index, just as it states: from sqlalchemy import create_engine, Integer, Index, Table, Column, MetaData from sqlalchemy.dialects.postgresql import JSON e =