python - 如何制作表分区?

标签 python sqlalchemy

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

非常感谢您的帮助。

最佳答案

划分有两种:垂直划分和水平划分。

来自docs :

Vertical Partitioning

Vertical partitioning places different kinds of objects, or different tables, across multiple databases:

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()

Horizontal Partitioning

Horizontal partitioning partitions the rows of a single table (or a set of tables) across multiple databases.

See the “sharding” example in attribute_shard.py

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

关于python - 如何制作表分区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1085304/

相关文章:

python - XPath 父节点的类不应包含特定字符串

python - 如何在 scrapy 契约(Contract)中向请求添加属性

python - psycopg2.编程错误: incomplete placeholder: '%(' without ')'

python - 删除 Flask-SQLAlchemy 表引发 AttributeError

python - SQLAlchemy:如何从多个表中选择最大值

Python - 合并来自多个线程实例的数据

python - 计算忽略重复的特定字符数 : Python

python - Flask SQLAlchemy - StaticMethod 与自定义查询类

sqlalchemy - 如何为 SQLAlchemy 编写外部方言?

python - 使用 sqlalchemy-cockroachdb 时导入作业消失