The problem is that I can not connect to the postgre database natively. Connecting via DSN works, but when I try to register the entire connection string myself, nothing comes out.
import pyodbc import random import time from datetime import datetime #cnxn = pyodbc.connect('DSN=PostgreTest;PWD=1234') conn_str = ( "DRIVER={PostgreSQL Unicode};" "DATABASE=postgres;" "UID=postgres;" "PWD=1234;" "SERVER=localhost;" "PORT=5432;" ) cnxn = pyodbc.connect(conn_str) cursor = cnxn.cursor() The error code is not clear at all:
Traceback (most recent call last): File "C:\TestProj\test.py", line 15, in <module> cnxn = pyodbc.connect(conn_str) Error: ('IM002', '[IM002] [Microsoft][\xc4\xe8\xf1\xef\xe5\xf2\xf7\xe5\xf0 \xe4\xf0\xe0\xe9\xe2\xe5\xf0\xee\xe2 ODBC] \xc8\xf1\xf2\xee\xf7\xed\xe8\xea \xe4\xe0\xed\xed\xfb\xf5 \xed\xe5 \xed\xe0\xe9\xe4\xe5\xed \xe8 \xed\xe5 \xf3\xea\xe0\xe7\xe0\xed \xe4\xf0\xe0\xe9\xe2\xe5\xf0, \xe8\xf1\xef\xee\xeb\xfc\xe7\xf3\xe5\xec\xfb\xe9 \xef\xee \xf3\xec\xee\xeb\xf7\xe0\xed\xe8\xfe (0) (SQLDriverConnect)') But when connected via DSN, in which everything is written the same, it works as it should. Why do I need to get rid of it through the line? There is another software that does not know how to connect through the LTOs, but it is necessary to use it.
Before writing a question here, previously google for this problem, the problem could not be solved.
[#<Encoding:Windows-1251>, "[IM002] [Microsoft][Диспетчер драйверов ODBC] Источник данных не найден и не указан драйвер, используемый по умолчанию (0) (SQLDriverConnect)"]for those who are interested in for shielded creepiness in the error message. - D-side