Peewee 本机压缩而不是 CompressedField
Peewee Native compression instead of CompressedField
我正在使用 peewee,我想在 MariaDB 中使用压缩字段。 table 是通过 SQL:
这样创建的
CREATE TABLE TableName
(
field_name BLOB COMPRESSED,
);
在 peewee 中 CompressedField
是 BlobField
的包装器。并非所有访问数据库的用户都使用 peewee,所以我想在 MariaDB 中使用 InnoDB 的内置透明压缩。在使用 peewee 的 create_tables()
时,我如何告诉 peewee 使用压缩创建字段 field_name
?
您可以非常非常轻松地添加自定义字段类型。这在文档中有描述:
http://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field
这应该是您所需要的:
class CompressedBlobField(BlobField):
field_type = 'BLOB COMPRESSED'
我正在使用 peewee,我想在 MariaDB 中使用压缩字段。 table 是通过 SQL:
这样创建的CREATE TABLE TableName
(
field_name BLOB COMPRESSED,
);
在 peewee 中 CompressedField
是 BlobField
的包装器。并非所有访问数据库的用户都使用 peewee,所以我想在 MariaDB 中使用 InnoDB 的内置透明压缩。在使用 peewee 的 create_tables()
时,我如何告诉 peewee 使用压缩创建字段 field_name
?
您可以非常非常轻松地添加自定义字段类型。这在文档中有描述:
http://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field
这应该是您所需要的:
class CompressedBlobField(BlobField):
field_type = 'BLOB COMPRESSED'