We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description session.commit() method produces IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint.
To Reproduce
class Currency(Base): __tablename__ = 'currency' currency_code = db.Column('currency_code', db.String(3), primary_key=True) currency_name = db.Column('currency_name', db.String(140)) Session = sessionmaker(bind=self.engine) session = Session() currency_list = [Currency(currency_code = 'USD'), Currency(currency_code = 'EUR')] currency_list = list(map(lambda x: session.merge(x), currency_list)) session.bulk_save_objects(currency_list, update_changed_only=False) session.commit()
Additional information
... currency_list = list(map(lambda x: session.merge(x), currency_list)) session.commit() session.bulk_save_objects(currency_list, update_changed_only=False) session.commit()
connection = psycopg2.connect(...) ... statement = "INSERT INTO {0} ({1}) VALUES ({2}); ".format(table, columns, values) crsr.execute(statement) connection.commit()
Error
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "currency_pkey" DETAIL: Key (currency_code)=(EUR) already exists.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
session.commit() method produces IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint.
To Reproduce
Additional information
Error
The text was updated successfully, but these errors were encountered: