Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Duplicate key values error is not thrown as exception and is getting ignored #255

Open
Labels
enhancement protocolrequires Vertica protocol knowledge
@flyninjacode

Description

I'm trying to capture 'Duplicate key values error ' message if there is any insert statement that is violating the primary key constraint. In the following code I created a 'demo' table with 'demo_id' as the primary_key and tried to insert the same row twice.
Example:
`connection = v.connect()
cursor = connection.cursor()
cursor.execute("""
DROP TABLE IF EXISTS demo;
CREATE TABLE demo (
demo_id integer primary key enabled,
code varchar(20),
quantity smallint,
amount money,
product_id int,
demo_date datetime);
""")
cursor.execute("""
INSERT INTO demo
SELECT 1,'RT0132',1,100,10023,now();

""")
cursor.execute("""
INSERT INTO demo
SELECT 1,'RT0132',1,100,10023,now();

""")
connection.commit()`
For the above code I would expect it to throw an Exception like "Message: b"Duplicate key values: 'demo_id=1' -- violates constraint", but it doesn't. Is there an existing solution to handle this case or can this issue be resolved by doing some quick workaround ?

I'm using Python 3.5.2 and vertica_python 0.8.2 versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement protocolrequires Vertica protocol knowledge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /