After I installed pyodbc by run pip install pyodbc-4.0.16-cp36-cp36m-win_amd64.whl
, I got unresolved import pyodbc in Eclipse. So I manually added "pyodbc" under Python Interpreter > Forced Builtins and "unresolved import pyodbc" issue solved in Eclipse.
However, auto completion does not work for variable in Eclipse with Pydev. I can get auto completion for pyodbc.connect
but not conn.cursor()
unless I define conn = pyodbc.Connection
.
Auto completion not working for variable conn
import pyodbc
if __name__ == '__main__':
conn = pyodbc.connect('Connecting String....')
cur = conn.Cursor()
Auto completion works for variable conn
import pyodbc
if __name__ == '__main__':
conn = pyodbc.Connection
conn = pyodbc.connect('Connecting String....')
cur = conn.Cursor()
This is mostly because PyDev can't infer what pyodbc.connect returns (it can't really execute that, it can only see that it's a method call and try to guess from its docstring).
You can help it though by adding type hints in docstrings as:
#: :type conn: pyodbc.Connection
See: http://www.pydev.org/manual_adv_type_hints.html for more info
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.