V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
15399905591
V2EX  ›  Python

postgresql 在 Python 订阅变化的问题

  •  
  •   15399905591 · 2020-03-21 10:34:01 +08:00 · 1992 次点击
    这是一个创建于 1503 天前的主题,其中的信息可能已经有所发展或是发生改变。
    希望在当前应用中监控某些表变化,之前想的方案是通过 sqlalchemy 的触发器去写,
    但是这个方案有两个弊端,一个是侵入式的,对程序不友好,二是该任务执行时间比较长,会影响性能,
    自己在网上查了下方案,发现 mysql 有一个 python-mysql-replication 库,但是 postgresql 的库没找到,
    有没有大佬有类似的库,或者有对应的解决方案,在这感谢大佬了。
    6 条回复    2020-03-21 20:07:46 +08:00
    virusdefender
        1
    virusdefender  
       2020-03-21 11:38:44 +08:00
    如果不是特别实时,记录最后更新时间定期检查就好了,你说的触发器应该是最直接的办法
    15399905591
        2
    15399905591  
    OP
       2020-03-21 11:41:14 +08:00
    @virusdefender 这里需要实时数据,通过定时器的话, 这个动作比较大。
    dzdh
        3
    dzdh  
       2020-03-21 12:38:16 +08:00
    这些不是应该是在发生变化的应用程序中实现的吗 为毛要扔给数据库
    tomczhen
        4
    tomczhen  
       2020-03-21 13:10:12 +08:00 via Android
    你这个需求叫 change data capture 简称 CDC,按关键字去搜就好。
    encro
        5
    encro  
       2020-03-21 14:19:38 +08:00
    定义 ORM 的 behaviors 的 event 可以啊。
    ericFork
        6
    ericFork  
       2020-03-21 20:07:46 +08:00
    debezium
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2190 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 05:19 · PVG 13:19 · LAX 22:19 · JFK 01:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.