26 lines
459 B
Python
26 lines
459 B
Python
import psycopg2
|
|
|
|
print('Can`t establish connection to database')
|
|
|
|
'''
|
|
conn = psycopg2.connect(
|
|
dbname="kolchin",
|
|
user="kolchin",
|
|
password="postgres",
|
|
host="pg",
|
|
port="5432"
|
|
)
|
|
|
|
cursor = conn.cursor()
|
|
|
|
with conn.cursor() as curs:
|
|
curs.execute(CREATE TABLE IF NOT EXISTS tablee(
|
|
name varchar(10) NOT NULL,
|
|
surname varchar,
|
|
city varchar,
|
|
age smallint
|
|
);)
|
|
conn.commit()
|
|
conn.close()
|
|
'''
|