W
W
wz2021-06-13 16:41:30
SQLite
wz, 2021-06-13 16:41:30

Error with port 5432 discord.py?

Gift to all who read. For the first time I work with databases and SQL in general.

I am making a bot that reads information from the sql2.7m.pl database. It gives an
error with port 5432, rummaged through the entire Internet in search of an answer and did not find it.
Mistake:

Traceback (most recent call last):
File "C:\Users\User\Downloads\theDashAPI\bot.py", line 13, in
conn = psycopg2.connect(host = "sql2.7m.pl", user = "db -user22172", password = "5d01d486", dbname = "db-user22172", port="5432")
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\psycopg2 \__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host " sql2.7m.pl" (149.202.75.212) and accepting
TCP/IP connections on port 5432?


The code:
conn = psycopg2.connect(
host = "sql2.7m.pl",
user = "db-user22172",
password = "пароль",
dbname = "db-user22172",
port="5432"
)

cursor = conn.cursor()

@bot.command(aliases=['acc', 'prof', 'profile'])
async def stats(ctx, username=None):
    author_name = ctx.author.display_name
    author_avatar = ctx.author.avatar_url

    if not username:
        emb = discord.Embed(title = f"Ошибка!", description = "Игрок не найден.", timestamp= ctx.message.created_at)
        emb.set_footer(text = f"Вызвал {author_name}", icon_url = author_avatar)
        await ctx.reply(embed=emb, mention_author=False)
        return
    
    user = cursor.execute(f'SELECT * FROM users WHERE userName = {username}')
    author_name = ctx.author.display_name
    author_avatar = ctx.author.avatar_url

    emb = discord.Embed(title=f'Статистика игрока: {user.userName}', desscription=f"""
    Айди: {user.userID}
    Звёзд: {user.stars}
    Демонов: {user.demons}
    Алмазы: {user.diamonds}
    Секрет коинов: {user.coins}
    Юзер коинов: {user.userCoins}""", timestamp=ctx.message.created_at)
    emb.set_footer(text=f'Вызвал {author_name}', icon_url = author_avatar)
    await ctx.reply(embed=emb, mention_author=False)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2021-06-13
@2ord

Is the server running on host "sql2.7m.pl" (149.202.75.212) and accepting
TCP/IP connections on port 5432?
a perfectly reasonable question is asked.
The DBMS is not available on the specified port and address.
What is this host
sql2.7m.pl
? Who serves him?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question