Python: decryption error or failed mac entry when calling from Thread

I get the error "decryption with error or write failure" in this code fragment:

conn = psycopg2.connect(...)
cursor = conn.cursor()
cursor.execute("SELECT id, ip FROM schema.table;")
rows = cursor.fetchall()
cursor.close()
conn.commit()
conn.close()

This is called in the run () Thread method several times at a time (True). I just open a connection to my PostgreSQL database using the psycopg2 driver.

Any idea on how safe it is to open db connections in threads in Python? I do not know what causes this error.

+4
source share
3 answers

, , . , , - . cursor.execute(...) , /.

conn = psycopg2.connect(...)
cursor = conn.cursor()
cursor.execute("SELECT id, ip FROM schema.table;")
rows = cursor.fetchall()
cursor.close()
conn.commit()
conn.close()
conn = None
+5

, () PostGres, . Django & PostGres BeanStalk.

'OPTIONS': {'sslmode': 'disable'} .

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': ...
        'USER': ....
        'PASSWORD': ...
        'HOST': ....
        'PORT': '5432',
        'OPTIONS': {
           'sslmode': 'disable',
        }
    }
}
0

Multiprocessing Postgresql Python. , , , , . , . !

0

All Articles