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
relic
V2EX  ›  Python

sqlalchemy 'metadata' is reserved

  •  
  •   relic · 2016-03-30 17:35:18 +08:00 · 2674 次点击
    这是一个创建于 2962 天前的主题,其中的信息可能已经有所发展或是发生改变。

    mysql 的某个 table 使用了 sqlalchemy 的 metadata 作为字段现在出问题了,有没有什么好的解决办法,在不改动数据库的情况下?

    sqlalchemy 源码中的注释

    we expect to see the name 'metadata' in some valid cases; however at this point we see it's assigned to something trying to be mapped, so raise for that.

    9 条回复    2016-03-31 10:30:05 +08:00
    DeanThompson
        1
    DeanThompson  
       2016-03-30 18:30:23 +08:00   ❤️ 1
    SQLAlchemy 的字段名和数据库的字段名可以不一样,`Column` 支持指定数据库里的字段名,如:

    mtdata = Column("metadata", String(50))

    在 Python 里使用的时候,引用的是 `mtdata`, SQLAlchemy 会映射到数据库里的 metadata 字段。
    greenmoon55
        2
    greenmoon55  
       2016-03-30 20:22:39 +08:00
    我也用了类似 LS 的方法
    sinux
        3
    sinux  
       2016-03-30 21:31:28 +08:00
    头像太美。
    relic
        4
    relic  
    OP
       2016-03-30 21:49:17 +08:00
    @sinux racket 现在发展的还好吗
    zhangxiao
        5
    zhangxiao  
       2016-03-30 22:03:30 +08:00
    @sinux 哈哈,不得不回复赞同一下
    sinux
        6
    sinux  
       2016-03-30 22:51:06 +08:00
    @relic 棒棒哒
    sinux
        7
    sinux  
       2016-03-30 22:51:23 +08:00
    @zhangxiao 暴露年龄 0 0
    cavalier1106
        8
    cavalier1106  
       2016-03-30 22:52:23 +08:00
    @sinux 魔兽世界 什么装备来的
    sinux
        9
    sinux  
       2016-03-31 10:30:05 +08:00
    @cavalier1106 忘记了,在 DOTA 里是圣者遗物
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   992 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 21:08 · PVG 05:08 · LAX 14:08 · JFK 17:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.