【问题标题】:Schemacrawler cannot output the schema from DB2 (and Oracle) server in JSON formatSchemacrawler 无法以 JSON 格式从 DB2(和 Oracle)服务器输出模式
【发布时间】:2020-07-18 03:36:19
【问题描述】:

我正在尝试使用SchemaCrawler 来提取关于 db2 测试数据库的架构信息。

以文本或 html 格式运行 schema 命令时,一切正常:

./schemacrawler.sh --server=db2 --host=127.0.0.1 --port=50000 --database=sample --schemas=DB2INST1 --user="db2inst1" --password=password --info-level=standard --command=schema --tables='.*\.P.*' 


System Information
========================================================================

generated by                              SchemaCrawler 16.9.2          
generated on                              2020-07-17 01:50:58.987909    



Tables
========================================================================



DB2INST1.PRODUCT                                                 [table]
------------------------------------------------------------------------
  PID                               VARCHAR(10) NOT NULL        
  NAME                              VARCHAR(128)                
  PRICE                             DECIMAL(30, 2)              
  PROMOPRICE                        DECIMAL(30, 2)              
  PROMOSTART                        DATE                        
  PROMOEND                          DATE                        
  DESCRIPTION                       XML                         

Primary Key

PK_PRODUCT                                                 [primary key]
  PID                                                           

Indexes

PK_PRODUCT                                                [unique index]
  PID                               ascending                   

(... and so on ...)

现在我想以 JSON 格式输出它以进行数据集成。所以我尝试运行schema命令,输出为json格式,但失败了(full log here):

SchemaCrawler 16.9.2

Error: Unknown command <schema>

Re-run SchemaCrawler with just the
-h
option for help

Or, re-run SchemaCrawler with an additional
--log-level=CONFIG
option for details on the error

我也试过the command serialize,也失败了(full log here):

SchemaCrawler 16.9.2

Error: Unknown command <serialize>

Re-run SchemaCrawler with just the
-h
option for help

Or, re-run SchemaCrawler with an additional
--log-level=CONFIG
option for details on the error

顺便说一句,在 Oracle 服务器上运行时,我也遇到了类似的问题。

那么,两个问题:

  1. 如何从 db2 服务器中提取 JSON 格式的模式信息?
  2. 如何为 Oracle 服务器做同样的事情?

谢谢。

【问题讨论】:

    标签: oracle db2 schemacrawler


    【解决方案1】:

    苏坦迪奥诺,

    您绝对可以为 IBM DB2 和 Oracle 数据库提取 JSON 格式的模式元数据。您的日志不完整,所以最后我看不到堆栈跟踪。不过,我可以看到,您的类路径中有 Jackson jar 文件,这很好。除此之外,您可以尝试使用额外的命令行参数--output-format json。 (如果可行,请告诉我。)在下一个 SchemaCrawler 版本中,您将收到更好的错误消息,例如“错误:命令不支持输出格式”,这将对您有所帮助。

    Sualeh Fatehi,SchemaCrawler

    【讨论】:

    • 嗨,@Sualeh Fatehi,感谢您对此进行调查。我已经上传了新的 gist over here 供您参考。这一个包括参数--output-format=json,我之前跳过了它,因为根据the changelog,JSON 输出在 16.2.2 中被删除。我们还尝试了serializedifferent error。谢谢。
    • Sutandiono,您需要使用序列化命令来输出 JSON。出于某种原因,Gist 仍在消除实际错误。您看到的问题可能与此处报告的问题相同 - github.com/schemacrawler/SchemaCrawler/issues/346 - 我正在调查该问题,因此请在 GitHub 上关注该主题。
    • 嗨,@Sualeh Fatehi,请查看此raw gist,它显示了serialize 上的完整错误。同时,我将在 github 上关注相同的报告问题。再次感谢您调查此问题。
    • 是的,这将在上面引用的问题 #346 中修复
    • 嗨,@Sualeh Fatehi,在这里回复是为了通知您该问题已在 SchemaCrawler 16.9.3 中得到解决。谢谢你的帮助,也谢谢你提供了这么棒的工具:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多