Q:

PostgreSQL creating table with Python failed

For some unknown reason table in database was not created. How to solve it?
import psycopg2
conn = psycopg2.connect(user='postgres', host='localhost', password='123456')
conn.autocommit = True
cur = conn.cursor()
cur.execute('CREATE DATABASE example;')
cur.execute("""CREATE TABLE HARMKA
                         (ID INT PRIMARY KEY NOT NULL,
                         PHARMACY_LICENSE CHAR(100),
                         STREET CHAR(150),
                         CITY CHAR(30));""")
cur.execute("INSERT INTO HARMKA VALUES(%s, %s, %s, %s)", (1, '12345', 'street', 'Denwer'))
cur.close()
conn.close()

A:

You need to connect to example database and then create tables and manipulate data.
conn = psycopg2.connect(database='example', user='postgres', host='localhost', password='123456')

