# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
+ 'Programming Language :: Python :: 3.10',
+ 'Programming Language :: Python :: 3.11',
],
# What does your project relate to?
'attrs',
'markupsafe',
'pgwui_common',
- 'psycopg2',
+ 'psycopg',
'pyramid',
],
-# Copyright (C) 2015, 2018, 2020, 2021 The Meme Factory, Inc.
+# Copyright (C) 2015, 2018, 2020, 2021, 2024 The Meme Factory, Inc.
# http://www.karlpinc.com/
# This file is part of PGWUI_Upload_Core.
import attr
import logging
import markupsafe
-import psycopg2.errorcodes
-from psycopg2 import ProgrammingError
+import psycopg.errors
from pgwui_core.core import (
UploadNullFileInitialPost,
ue UploadEngine instance
uh UploadHandler instance
insert_stmt Statement used to insert into db.
- (psycopg2 formatted for substituion)
+ (psycopg3 formatted for substituion)
'''
super(SaveLine, self).__init__(ue, uh)
self.insert_stmt = insert_stmt
' ON (pg_namespace.oid = pg_class.relnamespace)'
' WHERE pg_class.oid = %s::REGCLASS::OID'),
(qualified_table,))
- except ProgrammingError as err:
- pgcode = err.pgcode
- if pgcode == psycopg2.errorcodes.INVALID_SCHEMA_NAME:
- raise upload_ex.MissingSchemaError(
- 'No such schema',
- err.diag.message_primary,)
- elif pgcode == psycopg2.errorcodes.UNDEFINED_TABLE:
- raise upload_ex.MissingTableError(
- 'No such table or view',
- err.diag.message_primary,
- ('<p>Hint: Check spelling, database permissions, '
- ' or try qualifying the'
- ' table name with a schema name</p>'))
- elif pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
- raise upload_ex.InsufficientPrivilegeError(
- 'Your PostgreSQL login has insufficient privileges',
- err.diag.message_primary)
- else:
- raise
+ except psycopg.errors.INVALID_SCHEMA_NAME as err:
+ raise upload_ex.MissingSchemaError(
+ 'No such schema',
+ err.diag.message_primary,)
+ except psycopg.errors.UNDEFINED_TABLE as err:
+ raise upload_ex.MissingTableError(
+ 'No such table or view',
+ err.diag.message_primary,
+ ('<p>Hint: Check spelling, database permissions, '
+ ' or try qualifying the'
+ ' table name with a schema name</p>'))
+ except psycopg.errors.INSUFFICIENT_PRIVILEGE as err:
+ raise upload_ex.InsufficientPrivilegeError(
+ 'Your PostgreSQL login has insufficient privileges',
+ err.diag.message_primary)
+
return self.cur.fetchone()
def resolve_table(self, qualified_table):