【SQLAlchemy】PostgreSQL的自增长主键定义
生活随笔
收集整理的這篇文章主要介紹了
【SQLAlchemy】PostgreSQL的自增长主键定义
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
#coding=utf-8 #!/usr/bin/env?pythonfrom?sqlalchemy?import?create_engine engine?=?create_engine('postgresql://ms:ms@localhost:5432/stockpy') from?sqlalchemy.ext.declarative?import?declarative_base Base?=?declarative_base()from?sqlalchemy?import?Table,Column,?String,Integer,Sequenceclass?Test1(Base):__tablename__?=?'test1'id?=?Column(Integer,?Sequence('test1_id_seq'),?primary_key=True)name?=?Column(String(50))ed_t1=Test1(name='fuck?python') from?sqlalchemy.orm?import?sessionmaker Session?=?sessionmaker(bind=engine) session?=?Session() session.add(ed_t1) session.commit()轉載于:https://my.oschina.net/lbp0200/blog/499210
總結
以上是生活随笔為你收集整理的【SQLAlchemy】PostgreSQL的自增长主键定义的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 08.self关键字
- 下一篇: Linux 随机启动 Mysql