小编yor*_*rjo的帖子

使用sqlalchemy的声明性ORM扩展时,多列索引

根据文档sqlalchemy.Column类中的注释,我们应该使用该类sqlalchemy.schema.Index来指定包含多个列的索引.

但是,该示例显示了如何通过直接使用Table对象来执行此操作,如下所示:

meta = MetaData()
mytable = Table('mytable', meta,
    # an indexed column, with index "ix_mytable_col1"
    Column('col1', Integer, index=True),

    # a uniquely indexed column with index "ix_mytable_col2"
    Column('col2', Integer, index=True, unique=True),

    Column('col3', Integer),
    Column('col4', Integer),

    Column('col5', Integer),
    Column('col6', Integer),
    )

# place an index on col3, col4
Index('idx_col34', mytable.c.col3, mytable.c.col4)
Run Code Online (Sandbox Code Playgroud)

如果我们使用声明性ORM扩展,我们该怎么做?

class A(Base):
    __tablename__ = 'table_A'
    id = Column(Integer, , primary_key=True)
    a = Column(String(32))
    b = Column(String(32))
Run Code Online (Sandbox Code Playgroud)

我想要列"a"和"b"的索引.

python database indexing orm sqlalchemy

83
推荐指数
2
解决办法
3万
查看次数

使用Python日志记录格式的制表

我正在使用带有"本机"配置文件支持(config.fileconfig)的python日志记录模块,如下面的文档中所述:

http://docs.python.org/library/logging.html(参见logging.conf文件)

我想知道是否可以在配置文件中提供列表数据格式:

示例配置文件如下:

[formatter_simpleFormatter]  
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
Run Code Online (Sandbox Code Playgroud)

我虽然在格式中使用\ t就足够但它没有:

format=%(asctime)s\t%(name)s\t%(levelname)s\t%(message)s\t  
Run Code Online (Sandbox Code Playgroud)

我尝试了一些没有成功的事情.我想这很容易,但我找不到它!

我怎样才能做到这一点?

python logging

9
推荐指数
2
解决办法
5214
查看次数

pip wheel条件依赖

在开发用于开发python软件包的virtualenv的过程中,我经常使用“ pip wheel”发行。生成包装所需的所有车轮档案。我通过在setuptools extras_require参数中列出条件依赖项来开始使用它们。是否可以生成特定条件依赖项的车轮档案?

不支持类似“ pip wheel“。[conditional_feature]”的内容。(至少在python-2.7上)请注意,我可以使用以下命令在virtualenv中安装这些依赖项:pip install -e“。[conditional_feature]”

python pip python-wheel

5
推荐指数
1
解决办法
527
查看次数

标签 统计

python ×3

database ×1

indexing ×1

logging ×1

orm ×1

pip ×1

python-wheel ×1

sqlalchemy ×1