psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060) Python PostgreSQL ElephantSQL

-1

Here is my code. It was working perfectly fine, but I'm connected to a different network right now and I keep getting this error.

import psycopg2
from urllib.parse import urlparse,uses_netloc


uses_netloc.append("postgres")

#USE THE LINK TO YOUR ELEPHANT SQL FOR BELOW
url=urlparse('######################')


conn=psycopg2.connect(database=url.path[1:],
    user=url.username,
    password=url.password,
    host=url.hostname,
    port=url.port
)
    #global conn

cur=conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS InputUserSentiment(id serial PRIMARY KEY, Name Varchar(50), Sentiment Varchar(500));')
conn.commit()

cur=conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS PictureSentimentValues(id serial PRIMARY KEY, HappyScore float, NeutralScore float, SurpriseScore float, SadScore float, FearScore float, DisgustScore float, AngryScore float);')
conn.commit()

This is the error.

I don't know how to solve it.

python
sql
database
postgresql
asked on Stack Overflow Oct 6, 2018 by user9826208 • edited Oct 6, 2018 by user9826208

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0