Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/psycopg2/errors.py: 33%

3 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1"""Error classes for PostgreSQL error codes 

2""" 

3 

4# psycopg/errors.py - SQLSTATE and DB-API exceptions 

5# 

6# Copyright (C) 2018-2019 Daniele Varrazzo <daniele.varrazzo@gmail.com> 

7# Copyright (C) 2020-2021 The Psycopg Team 

8# 

9# psycopg2 is free software: you can redistribute it and/or modify it 

10# under the terms of the GNU Lesser General Public License as published 

11# by the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# In addition, as a special exception, the copyright holders give 

15# permission to link this program with the OpenSSL library (or with 

16# modified versions of OpenSSL that use the same license as OpenSSL), 

17# and distribute linked combinations including the two. 

18# 

19# You must obey the GNU Lesser General Public License in all respects for 

20# all of the code used other than OpenSSL. 

21# 

22# psycopg2 is distributed in the hope that it will be useful, but WITHOUT 

23# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 

24# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 

25# License for more details. 

26 

27# 

28# NOTE: the exceptions are injected into this module by the C extention. 

29# 

30 

31 

32def lookup(code): 

33 """Lookup an error code and return its exception class. 

34 

35 Raise `!KeyError` if the code is not found. 

36 """ 

37 from psycopg2._psycopg import sqlstate_errors # avoid circular import 

38 return sqlstate_errors[code]