SQLACODEGEN + VSCODE + Intellisense not working.

278 views
Skip to first unread message

Jeremy Flowers

unread,
May 11, 2018, 1:07:16 PM5/11/18
to sqlalchemy
I have some code in VS Code...

  jobrow = session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']).first()



Jobmst is imported from a single module I've created called tidal.py

jobrow is an instance of Jobmst...

But I can't select any of the columns.

I've tried 

http://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/quickstart.html (Steps 1..3 -> Then python install .\dist\<modulename>.tar.gz

After reading both these:

https://stackoverflow.com/a/30608672/495157

https://stackoverflow.com/questions/31384639/what-is-pythons-site-packages-directory


Then found that pip install rather than python install is way to go...

Since uninstalling causes issues per this comment:

https://stackoverflow.com/questions/37856569/pip-uninstall-working-but-giving-error


have just deleted folders in the.

<python-install>\Lib\site-packages folder 

an egg.info folder and module folder)



I have this in my setup.py:

from distutils.core import setup
setup
(
    name
='TidalConversion',
    version
='0.1dev',
    packages
=['tidalconversion',],
    license
='Creative Commons Attribution-Noncommercial-Share Alike license',
    long_description
=open('README.txt').read(),
)


I have this in my __init__.py:

#!/usr/bin/env python
import os
from tidal import *
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
engine
= create_engine(os.environ['DATABASE_URL'], echo=False) #echo='debug'
Session = sessionmaker(bind=engine)


tidal is the file that contains the sqlacodegen generated classes - including the Jobmst class I can't get Intellisense on.


In my main code I have..

from tidalconversion import Session, engine, Jobmst

(tidalconversion is my module name I'm packaging stuff up in)


This is what my folder structure looks like:


Can someone advise what i have to do in order to get Intellisense working in VS Code?

Jeremy Flowers

unread,
May 11, 2018, 7:32:40 PM5/11/18
to sqlalchemy
I've also been looking at here in the hope of finding a solution.
I tried setting this in the VS Code (Version 1.23.1) 'User Settings' tab (File -> Preferences -> Settings) 
"python.autoComplete.extraPaths": ["c:\\opt\\tidalconversion\tidal.py"]

The exiting and relaunching IDE. Alas that didn't work either..

Jeremy Flowers

unread,
May 11, 2018, 7:38:42 PM5/11/18
to sqlalchemy
Also tried this in extrapaths - no joy either: 
${workspaceRoot}
Per this thread

Jeremy Flowers

unread,
May 12, 2018, 4:17:29 AM5/12/18
to sqlalchemy
Have recorded a video showcasing issue.

Jeremy Flowers

unread,
May 12, 2018, 4:58:26 AM5/12/18
to sqlalchemy
Have posted on Stack Overflow here

Message has been deleted

Jeremy Flowers

unread,
May 13, 2018, 5:52:25 AM5/13/18
to sqlalchemy

I got some feedback on Stack Overflow that sounds promising..
Does SQLAlchemy by any chance use Doctstrings to indicated return types?
Seems PyCharm Python IDE may have a work around for this?
See:

Jeremy Flowers

unread,
May 13, 2018, 6:06:28 AM5/13/18
to sqlalchemy
I'd say specifically for this part:
 

  jobrow 
= session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']).first()

That first method at the end... 

Jeremy Flowers

unread,
May 13, 2018, 6:38:37 AM5/13/18
to sqlalchemy
I added PEP0526 code hint and that fixed it.
   jobrow = session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']).first() # type: Jobmst

Is it feasible for the SQLAlchemy tool to correctly add these a the library level?
It would be preferable to my client code!

Mike Bayer

unread,
May 13, 2018, 10:55:17 PM5/13/18
to sqlal...@googlegroups.com
if you mean SQLAlchemy would have type hinting internally, while that
might be something we do at some point I don't see how it helps the
issue of knowing what Query.first() returns, because that type is not
static. At the source code level, Query.first() returns a subclass
of "object".



>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> 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+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages