user6640983
user6640983

Reputation:

Psycopg2 shows error

From my understanding psycopg2 comes installed with the Python 2.7. When I run the following module it returns an error.

import psycopg2
import sys

conn = none

Traceback (most recent call last):
File "C:/Programming/psycopg2.py", line 1, in<module>
import psycopg2
File "C:/Programming\psycopg2.py", line 4, in<module>
conn = none
NameError: name 'none' is not defined

Upvotes: 1

Views: 1836

Answers (1)

Pocketsand
Pocketsand

Reputation: 1281

The "none" is a built in constant which needs to be capitalised:

import psycopg2
import sys

conn = None

The error occurs because the Python interpreter thinks you are trying to reference a variable named 'none' which does not exist in your code.

Upvotes: 1

Related Questions