我将 MySQL 与 SQLAlchemy 一起使用。我有一个这样定义的类:
Base = sqlalchemy.ext.declarative.declarative_base()
class process(Base):
__tablename__ = 'processes'
process = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, nullable=False)
get_javascript = sqlalchemy.Column(sqlalchemy.types.Boolean, nullable=False)
我的架构定义如下:
CREATE TABLE processes
(
process Mediumint NOT NULL AUTO_INCREMENT,
get_javascript Varchar(1) NOT NULL,
PRIMARY KEY (process)
) ENGINE = InnoDB
在我的数据库中,我有以下行:
+---------+----------------+
| process | get_javascript |
+---------+----------------+
| 17 | 0 |
| 18 | 1 |
+---------+----------------+
在 Python 中查询它们总是让我对这个get_javascript
领域很满意。
>>> for i in s.query(db_classes.process).all():
... print i.process, i.get_javascript
...
17 True
18 True