Tiago Stapenhorst
Tiago Stapenhorst

Reputation: 766

Code completion not working in PyCharm

I am trying to get code completion for the psycopg2 library in PyCharm 2018.1 but it is not showing cursor class methods like .execute() or .fetchone().

Here is my code:

import logging
import psycopg2 as pg

#Code completion works fine here.
logger = logging.getLogger()
logger.info("Hello World!")

#Code completion works fine here.
con = pg.connect("dbname='postgres' port='5432'")

#Code completion not working!
cur = con.cursor()

Upvotes: 2

Views: 525

Answers (2)

Wotori Movako
Wotori Movako

Reputation: 326

In my case the solution is to reset the settings. From the main menu, select File > Manage IDE Settings > Restore Default Settings.

Alternatively, press Shift twice and type Restore default settings

Upvotes: 0

vishes_shell
vishes_shell

Reputation: 23554

That's because:

Psycopg 2 is mostly implemented in C as a libpq wrapper

So you have autocomletion for pg.connect() because it exists in __init__.py and mostly the rest of features are listed as .c and .h files https://github.com/psycopg/psycopg2/tree/master/psycopg that are being handled by setup.py.

Upvotes: 3

Related Questions