LionHeart123 / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

sqlalchemy autocomplete #584

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. import sqlalchemy
2. create scoped session
3. type : session.q

expected output : session.query(
instead :  session.query_property(
version : 2.4.3

Original issue reported on code.google.com by Ski...@gmail.com on 28 Nov 2011 at 10:21

GoogleCodeExporter commented 9 years ago
This is consistent with the documentation from 
http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.scoping.ScopedSes
sion.query_property:  

class sqlalchemy.orm.scoping.ScopedSession(session_factory, scopefunc=None)

    Provides thread-local management of Sessions.

    Typical invocation is via the scoped_session() function:

    Session = scoped_session(sessionmaker())

    The internal registry is accessible, and by default is an instance of ThreadLocalRegistry.

    See also: Contextual/Thread-local Sessions.

    configure(**kwargs)

        reconfigure the sessionmaker used by this ScopedSession.

    query_property(query_cls=None)

        return a class property which produces a Query object against the class when called.

        e.g.:

        Session = scoped_session(sessionmaker())

        class MyClass(object):
            query = Session.query_property()

        # after mappers are defined
        result = MyClass.query.filter(MyClass.name=='foo').all()

        Produces instances of the session’s configured query class by default. To override and use a custom implementation, provide a query_cls callable. The callable will be invoked with the class’s mapper as a positional argument and a session keyword argument.

        There is no limit to the number of query properties placed on a class.

    remove()

        Dispose of the current contextual session.

You can add sqlalchemy to the list of special packages (Tools, Options, IDE 
Options), so that you get the same autocompletion as in the interpreter, which 
is based on introspection instead of source code scanning.

Original comment by pyscripter on 21 Dec 2011 at 7:11