Jason Chu wrote:
> You can apply a unique index in Postgres (no idea about mysql or sqlite).
> [...]
> contactCategoryUserIndex = DatabaseIndex("name", "owner", unique=True)

This works in MySQL exactly the same way, too.

Unfortunately, handling duplicate-exeptions has changed during SO versions. If
you do not want to rely on a particular version you will have to catch
exceptions as follows:
        except DuplicateEntryError:
            return dict(success=False, error=...)
        except OperationalError, e:
            if str(e).startswith('Duplicate entry'):
                return dict(success=False, error=...)
With the latter being rather unreliable as MySQL error messages can be
configured to be e.g., in German.

-- W-Mark Kubacki

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to