Create table with psycopg2 on postgreSQL DB - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Create table with psycopg2 on postgreSQL DB (/thread-20599.html) |
Create table with psycopg2 on postgreSQL DB - yhecohen - Aug-21-2019 Hello everyone, that's my first time on this forum, but maybe not the last: I have a problem, i want to create a table in a postgreSQL DB that i created. When i launch my program to create this table, i recieve a psycopg2.Operationalerror with no information about this error. Maybe someone can help me ? Thank you very much. import psycopg2 def create_table(): conn=psycopg2.connect("dbname='DB1' user='postgres' password='shakD6yc' host='localhost' port='5432'") cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS store (item TEXT, quantity INTEGER, price REAL)") conn.commit() conn.close() create_table()And this is what appears in my console when i launch:
RE: Create table with psycopg2 on postgreSQL DB - Larz60+ - Aug-22-2019 Error shows that it either couldn't connect, or perhaps a connection timed out. RE: Create table with psycopg2 on postgreSQL DB - massimo_m - Aug-23-2019 the parameters have to be separated by , |