2

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()
1
  • 1
    What does not working mean? What happens when you are editing code? Have you contacted Jet Brains? Commented Apr 8, 2018 at 0:02

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.