if I might make a suggestion -

why are negative numbers being used as surrogate primary key values ?

I don't believe there's any restriction in SQLAlchemy as to this, but it seems 
a bit suspect.


On May 21, 2013, at 2:13 PM, Etienne Rouxel <rouxel.etie...@gmail.com> wrote:

> @Charlie Clark:
> In the documentation 
> (http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#session-frequently-asked-questions
>  see "Is the Session a cache ?"), it is mentioned that it does not 
> necessarily performs a query.
> 
> @Simon King:
> I guess you're the King indeed, I tried:
> 1. to assign the result of the 3 queries to 3 different variables
> 2. to assign the result of the 3 queries to the same variable
> 3. to assign the result of the first query to a variable and not to assign 
> the result of the 2 last queries
> In all these cases, only 1 SQL query were sent so your suspicion looks 
> correct.
> 
> Thank you both.
> 
> Le mardi 21 mai 2013 17:31:10 UTC+2, Etienne Rouxel a écrit :
> Hello
> In my program, I was trying to guess why so many SQL queries were sent while 
> some could have been avoided with the help of the identity map.
> So, I reduced my program to what is below and wrote 3 times the same 
> query.get call and 3 SQL queries were sent to the database server.
> Why does SQLAlchemy send 3 times the SQL while it could have done it only 1 
> time for the first call and use the identity map for the 2 last calls?
> 
> from sqlalchemy import *
> from sqlalchemy.orm import *
> from sqlalchemy.ext.declarative import declarative_base
> Base = declarative_base()
> 
> _descriptiontype_table = Table('descriptiontype', Base.metadata,
>         Column('id', Integer, primary_key=True),
>         Column('refno', Integer),
>         Column('sortindex', Integer),
>         Column('designation', String),
>         schema='botany'
>     )
> 
> class Descriptiontype(Base):
>     __table__ = _descriptiontype_table
> 
> if __name__ == '__main__':
> 
>     engine = create_engine('postgresql://user@localhost:5432/mydatabase')
>     Session = sessionmaker(bind=engine)
>     session = Session()
> 
>     session.query(Descriptiontype).get(-2147483648)
>     session.query(Descriptiontype).get(-2147483648)
>     session.query(Descriptiontype).get(-2147483648)
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to