I have a postgresql database established. I run the following code to get unique values in the 'state' column of the table (these are strings that represent FIPS numbers):
import psycopg2 as ps
con = ps.connect("dbname=example_db user=user password=password")
cursor = con.cursor()
cursor.execute('SELECT DISTINCT(%s) FROM example_table', ('state',))
results = cursor.fetchall()
This returns:
results
('state',)
If I run the same query in PGAdmin4 I get:
example_db=# SELECT DISTINCT state FROM example_table;
state
-------
06
(1 row)
I want to get the distinct values (i.e., 06, in this case) using psycopg2. What do I need to change?