Python 在哪里可以找到 Flask SQLAlchemy 列类型和选项的列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30137806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 07:59:53  来源:igfitidea点击:

Where can I find a list of the Flask SQLAlchemy Column types and options?

pythonsqlalchemyflask-sqlalchemy

提问by k4kuz0

I hope the word "Types" is used correctly here. Perhaps I mean "Arguments". Feel free to edit.

我希望在这里正确使用“类型”这个词。也许我的意思是“参数”。随意编辑。

I am creating a database using Models with Flask with SQLAlchemy, where can I find a list of all the different possible Column arguments such as:

我正在使用带有 Flask 和 SQLAlchemy 的模型创建一个数据库,在哪里可以找到所有不同可能的列参数的列表,例如:

account_id = db.Column(db.Integer, nullable=False)

account_id = db.Column(db.Integer, nullable=False)

I know some of the obvious types such as db.Integeror db.String. However I can't seem to find in the SQL Alchemy documentation, or the Flask documentation, a list of all possible arguments for creating a db.Columninstance. Am I looking wrong?

我知道一些明显的类型,例如db.Integeror db.String。但是,我似乎无法在 SQL Alchemy 文档或 Flask 文档中找到用于创建db.Column实例的所有可能参数的列表。我看错了吗?

Is there a way of differentiating things like db.Integerinto tinyint, bigint, etc.?

有没有办法将事物区db.Integer分为 tinyint、bigint 等?

As for options, such as the nullable=False, I have had trouble finding a good list of all the possible options when creating a db.Columninstance.

至于选项,例如nullable=False,我在创建db.Column实例时很难找到所有可能选项的完整列表。

采纳答案by Adam Matan

I think you're looking for the Column and Data Typespage in the documentation. A little HTML parsing gives:

我认为您正在文档中查找列和数据类型页面。一些 HTML 解析给出:

  • BIGINT
  • BINARY
  • BLOB
  • BOOLEAN
  • BigInteger
  • Boolean
  • CHAR
  • CLOB
  • Concatenable
  • DATE
  • DATETIME
  • DECIMAL
  • Date
  • DateTime
  • Enum
  • FLOAT
  • Float
  • INT
  • INTEGER
  • Integer
  • Interval
  • LargeBinary
  • MatchType
  • NCHAR
  • NVARCHAR
  • Numeric
  • PickleType
  • REAL
  • SMALLINT
  • SchemaType
  • SmallInteger
  • String
  • TEXT
  • TIME
  • TIMESTAMP
  • Text
  • Time
  • TypeDecorator
  • TypeEnginBases
  • TypeEngine
  • Unicode
  • VARBINARY
  • VARCHAR
  • 大数据
  • 二进制
  • BLOB
  • 布尔值
  • 大整数
  • 布尔值
  • 字符
  • CLOB
  • 可连接
  • 日期
  • 约会时间
  • 十进制
  • 日期
  • 约会时间
  • 枚举
  • 漂浮
  • 漂浮
  • 情报局
  • 整数
  • 整数
  • 间隔
  • 大二进制
  • 比赛类型
  • NCHAR
  • NVARCHAR
  • 数字
  • 泡菜类型
  • 真实的
  • 小灵通
  • 模式类型
  • 小整数
  • 细绳
  • 文本
  • 时间
  • 时间戳
  • 文本
  • 时间
  • 类型装饰器
  • 类型引擎库
  • 类型引擎
  • 统一码
  • VARBINARY
  • VARCHAR

回答by Sinux

Documentation is directly perceived through the senses, but if you still wanna see it in commandline, try some IDE, or just type this: (normally our dbis just SQLALCHEMY())

文档是通过感官直接感知的,但是如果您仍然想在命令行中看到它,请尝试一些 IDE,或者只需键入:(通常我们db只是SQLALCHEMY()

>>> print dir(sqlalchemy.types)
["ARRAY","BIGINT","BINARY","BLOB","BOOLEAN","BigInteger","Binary","Boolean","CHAR","CLOB","Concatenable","DATE","DATETIME","DECIMAL","Date","DateTime","Enum","FLOAT","Float","INT","INTEGER","Indexable","Integer","Interval","JSON","LargeBinary","MatchType","NCHAR","NULLTYPE","NUMERIC","NVARCHAR","NullType","Numeric","PickleType","REAL","SMALLINT","STRINGTYPE","SchemaType","SmallInteger","String","TEXT","TIME","TIMESTAMP","Text","Time","TypeDecorator","TypeEngine","Unicode","UnicodeText","UserDefinedType","VARBINARY","VARCHAR","Variant"]

回答by Samuel Ev