sqlalchemy中Sequence

Familiar with the CREATE TABLE command user may notice here VARCHAR did not specify the length, in SQLite and Postgresql, this is a legitimate type of data, but in other databases, which is not allowed. So if it is running in the other data in the present example, you also need to  String  specified length Type: ... the Column ( 'name', String (50))  String  field name length as well as other controllable precision: IntegerNumeric etc., only when creating a table in SQLAlchemy in. Further, Firebird and Oracle database need to create a new primary key identifier by serialization for, SQLAlchemy not automatically generated. For such cases, you must specify the  Sequence  generation:

>>> from sqlalchemy import Sequence ... A complete the Column ( 'ID', Integer, Sequence ( 'user_id_seq'), primary_key = True)  the Table  examples are as follows:

>>> users_table = Table('users', metadata, ... 

  Column('id', Integer, Sequence('user_id_seq'), primary_key = True), ... 

  Column('name', String(50)), ...

     Column('fullname', String(50)), ...

  Column('password', String(12)))

Guess you like

Origin www.cnblogs.com/pythonwenma/p/12664196.html