python - sqlalchemy primary key without auto-increment -


i'm trying establish table layout approximately following:

class widget(db.model):     __tablename__ = 'widgets'     ext_id = db.column(db.integer, primary_key=true)     w_code = db.column(db.string(34), unique=true)     # other traits follow... 

all field values provided through external system, , new widgets discovered , of omitted trait values may change on time (very gradually) ext_id , w_code guaranteed unique. given nature of values ext_id behaves ideally primary key.

however when create new record, specifying ext_id value, value not used in storage. instead values in ext_id follow auto-increment behavior.

>>> # clean database >>> skill = widget(ext_id=7723, w_code=u'igf35ac9') >>> session.add(skill) >>> session.commit() >>> skill.query.first().ext_id 1 >>>  

how can specify sqlalchemy ext_id field should used primary key field without auto-increment?

note: add synthetic id column primary key , make ext_id unique column instead both complicates code , adds (minimal) bloat database , i/o it. i'm hoping avoid that.

issue originated larger project able create smaller repro.

testing sqlite

set autoincrement=false disable creating sequence or serial primary key.

ext_id = db.column(db.integer, primary_key=true, autoincrement=false) 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -