Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLAlchemy is Throwing an IntegrityError due to a DBSession.add()
    primarykey
    data
    text
    <p>On the second time line 121 is called in this script <a href="http://paste.pocoo.org/show/520040/" rel="noreferrer">http://paste.pocoo.org/show/520040/</a>, I receive this error message:</p> <pre><code>*** IntegrityError: (IntegrityError) duplicate key value violates unique constraint "heroes_pkey" DETAIL: Key (id)=(14) already exists. 'INSERT INTO heroes (id, name, description, image_name, default_filename, faction, stat, roles, strength, agility, intelligence, strength_gain, agility_gain, intelligence_gain, min_hp, max_hp, min_mana, max_mana, min_damage, max_damage, armor, movespeed, attack_range, min_attack_animation, max_attack_animation, min_cast_animation, max_cast_animation, base_attack_time, missile_speed, day_site_range, night_site_range, resource_name, "order") VALUES (%(id)s, %(name)s, %(description)s, %(image_name)s, %(default_filename)s, %(faction)s, %(stat)s, %(roles)s, %(strength)s, %(agility)s, %(intelligence)s, %(strength_gain)s, %(agility_gain)s, %(intelligence_gain)s, %(min_hp)s, %(max_hp)s, %(min_mana)s, %(max_mana)s, %(min_damage)s, %(max_damage)s, %(armor)s, %(movespeed)s, %(attack_range)s, %(min_attack_animation)s, %(max_attack_animation)s, %(min_cast_animation)s, %(max_cast_animation)s, %(base_attack_time)s, %(missile_speed)s, %(day_site_range)s, %(night_site_range)s, %(resource_name)s, %(order)s)' {'day_site_range': 1800, 'min_damage': 47, 'intelligence': 18.0, 'agility': 14.0, 'night_site_range': 800, 'min_attack_animation': 0.4, 'id': 66666, 'attack_range': 128, 'default_filename': None, 'strength_gain': 2.7, 'strength': 21.0, 'min_hp': 549, 'armor': 1.96, 'intelligence_gain': 1.5, 'movespeed': 300, 'max_hp': 1765, 'max_cast_animation': 0.51, 'stat': 'Strength', 'resource_name': None, 'description': None, 'faction': 'Radiant', 'missile_speed': 0, 'image_name': None, 'max_damage': None, 'min_cast_animation': 0.4, 'max_mana': 702, 'name': None, 'roles': 'Carry / Pusher', 'base_attack_time': 1.7, 'agility_gain': 1.3, 'min_mana': 234, 'max_attack_animation': 0.3, 'order': 4} </code></pre> <p>I understand that the reason I am most likely getting this error, is b/c the previous session.add() is trying to add a record to the database with a primary key that already exists. The part I don't understand, is usually this happens automatically while using Postgresql, so why is this situation unique that the auto-increment isn't happening automatically on the add(). It is also important to the note, that the number in this part of the error message "(id)=(14)" increments by one with each successful call of the script.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload