如何制作表分区?

Rya*_*yan 2 python sqlalchemy

我对数据库不是很熟悉,所以我不知道如何使用SQLAlchemy对表进行分区。

您的帮助将不胜感激。

nos*_*klo 5

分为两种:垂直分区和水平分区。

从文档:

垂直分区

垂直分区可在多个数据库中放置不同种类的对象或不同的表:

engine1 = create_engine('postgres://db1')
engine2 = create_engine('postgres://db2')
Session = sessionmaker(twophase=True)
# bind User operations to engine 1, Account operations to engine 2
Session.configure(binds={User:engine1, Account:engine2})
session = Session()
Run Code Online (Sandbox Code Playgroud)

水平分区

水平分区将单个表(或一组表)的行跨多个数据库进行分区。

请参阅中的“分片”示例 attribute_shard.py

只是问您是否需要有关这些的更多信息,最好提供有关您想做什么的更多信息。