PyCharm SQLAlchemy autocomplete
pycharm, pyramid, python, sqlalchemy
Solution
The solution I've found to this (picked up from somewhere on the web) was to type hint the DBSession instance like this:
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
""":type: sqlalchemy.orm.Session"""
After this the code completion seems to work fine everywhere in the project
Problem
I started evaluating PyCharm 3 professional edition because I will be working on several Pyramid + SQLAlchemy projects. One of the things I would really love to have is SQLAlchemy autocomplete. I created a new starter project with the alchemy scaffold following these instructions. I also installed the SQLAlchemy package for the interpreter and virtual environment I am using for this project. Also, when I created a new pycharm project for this code, the IDE suggested me to install the pyramid, sqlalchemy and other packages. Of course I accepted the suggestion and let the IDE install all of those packages. In the `models.py` file, the DBSession is declared as follows: ``` DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) ``` In the views.py file, the DBSession is used this way: ``` one = DBSession.query(MyModel).filter(MyModel.name == 'one').first() ``` So I started playing with the IDE and did something like this: typed DBSession. and the IDE just gave me some few suggestions, within which the 'query' function was not listed. Then I tried typing: `DBSession.query(MyModel)`. and pressed `Ctrl+Space` to try to get suggestions and a 'No suggestions' message showed up. I would really like to have the SQLAlchemy suggestions of functions that I could use on my DBSession variable (like `filter`, `filter_by`, `first`, etc). I would say that this is mandatory for me :) Is there something I am missing? Or, PyCharm doesn't support this?