Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g84ue-0002gA-8b for psycopg@arkaria.postgresql.org; Thu, 04 Oct 2018 14:47:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g84uc-0000Pr-EE for psycopg@arkaria.postgresql.org; Thu, 04 Oct 2018 14:47:34 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g84uc-0000Pk-31 for psycopg@lists.postgresql.org; Thu, 04 Oct 2018 14:47:34 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g84uZ-00016B-4v for psycopg@lists.postgresql.org; Thu, 04 Oct 2018 14:47:32 +0000 Received: by mail-lj1-x236.google.com with SMTP id u21-v6so8620001lja.8 for ; Thu, 04 Oct 2018 07:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dEOfuy6Ylj85lGHC9cDWPx1FXhpiMBSjdTXm+D8YEUY=; b=W5BWXDSJzgUQYl+ZRWXK4lWAt3bkvcmLSyWnRdGZmDmsac4ZtMHIVbn1VkqQTssY4u nKjHU5NLpBYOAK2R35oDkqHcGrFbfs4cE93h913h39Ev8q3FEJ3apaUOkKNWu46q2LVN /JbbKrkppLb8Wq17JIvaGIcDzxwPmK/DoGlhayOXgof+UUqprWgzecZFfXFXbadAyfWo cdbHM/b1a+D8RD2pCKpJVsC7cbXQpJsOe46CTtqVhvAae3zLaCmVIXXvi+GbUEilj9hg Rc/nGZJ2VcuXs6gCu0H8q2VsI3o6hCms6SBVXd7Bk5WlHEYYWaEvt8zWloJZmy3RZpye a3Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dEOfuy6Ylj85lGHC9cDWPx1FXhpiMBSjdTXm+D8YEUY=; b=hMSqy+6hMTjl7N2XP79J6tfcbaoeHdkOG0UsjAcdWcwLsrvyP3wbTX1HoIBUxek/Uf YgBZpGpvIswRkXPKYRs9z/SxdTLIlYZKrRLcwbBBfeppt3aNz7/D3+l1a5Qq/PrGJYyF XKh0zzfRLQ40fc+tZD3ykJ3kLA+snM7tuenw14YjsPUDO+0QYXw2JnlhoYi+i6f/dBkM 9+lOY1Us6BMIIj8pitQwG+BJoiOZ8K2+oNCTytuX4QCjIduMw3LHyZbz4sMYsu46xvB7 WjoCoUiAqHNW6LZsPvDHRw7gD8KLCwu7M2zC9RGkXshB30jscQ5fH/z/ftucBkAIDA1D fSJQ== X-Gm-Message-State: ABuFfoiobrsTcCrQpftfWGsfCSSwaMYgb1RNPc9bR/4rB4XeqNA4eqYl yIO9zaR07PGVQK0su1IbjHzh9rBfoLJGwzV1JenRhJ+E X-Google-Smtp-Source: ACcGV61wm4WxaVWFwYDpcx115uSkQZjUaGkDNbq3O76dGY5kobFpp5bbDj1JGOT142ioWerfmRo+MsVjQcMFMZ3TOpU= X-Received: by 2002:a2e:9e99:: with SMTP id f25-v6mr4405241ljk.142.1538664449217; Thu, 04 Oct 2018 07:47:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniele Varrazzo Date: Thu, 4 Oct 2018 15:47:17 +0100 Message-ID: Subject: Re: Plans for 2.8 To: Michael Bayer Cc: psycopg@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Oct 4, 2018 at 3:18 PM Mike Bayer wrote: > I can't provide any suggestions, as the feature is very reasonable and > useful. But I will lament that pep-249 has nothing about this, which > means from a driver-agnostic point of view, the situation is pretty > much unchanged. Here's code I wrote for Openstack to try to apply > more specificity to database errors, basically a library of regexes: > https://github.com/openstack/oslo.db/blob/master/oslo_db/sqlalchemy/exc_filters.py#L55 Uhm, they also have the problem of not working if the message is localised... :\ With postgres it woud have been more robust to look at the extension `pgcode` but of course that's not portable either. Is there anything in common to all the databases which might be exposed in an uniform way by the drivers? e.g. the pgcode is actually something more standard than just postgres: "sqlstate" (or, SQLSTATE, because '70s) is supposed to be a standard. If you know that many/all the database emit a sqlstate you may suggest the dbsig to bless an exception attribute - e.g. `Exception.sqlstate` - to report it. Of course if postgres says "40P01" and IBM DB2 says "0911N" to report a deadlock, that's way out of what we can control... > one thing that would be helpful would be if your fine-grained > exception classes included more context about the failure. Like > UndefinedTable would include the table name as an individual > datamember e.g. exception.table_name, an error about a foreign key > constraint would include the constraint name e.g. > exception.constraint_name, things like that. You can see in my > oslo.db library above we are also pulling out other elements from the > error message to provide more context. We do already: more details about the exception, if made available by the database, are made available by the exception `diag` attribute: see . -- Daniele