解析 .NET 中的命令输出

发布于 2024-07-11 05:45:56 字数 297 浏览 11 评论 0原文

我想连接到 .NET 应用程序中的数据库服务器并执行生成一系列数据库统计信息的数据库命令。 问题是它不会以结构化格式返回统计信息,而是以纯文本形式返回(就像 UNIX 中的 df -k 命令)我可以捕获输出并解析它,但我想知道是否有更好的方法来处理类似的事情。

我当然想不出替代方案,但我想四处询问。 解析命令结果似乎有点脆弱,因为如果数据库作者更改了格式,我就会崩溃。

编辑: 该数据库是 IBM UniData 数据库。 该命令是“file.stat”,它返回平均记录大小、最大记录大小等。

I want to connect up to a database server in my .NET app and execute a database command that produces a series of database statistics. The problem is that it doesn't return the stats in a structured format, it returns it in plain text (like a df -k command in UNIX) I can capture the output and parse it, but I was wondering if there's a better approach to something like this.

I certainly can't think of an alternative, but I wanted to ask around. It seems a little fragile to be parsing the command results because if the database author ever changes the format, I break.

Edit: The database is an IBM UniData database. The command is "file.stat" and it returns the average record size, max record size, etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

口干舌燥 2024-07-18 05:45:56

是的,解析描述。 但是,您应该首先检查数据库版本。

:version
Module Name         Version   Licensed
UniData RDBMS............ 7.1     Yes

这样,如果 file.stat 数据发生变化,您可以调用备用例程。
注意: file.stat 输出数据在一段时间内是静态的,并且不太可能更改。

:file.stat TEST

File name                             = TEST
Number of groups in file (modulo)     = 3
Static hashing, hash type             = 0
Block size                            = 2048
Number of records                     = 12
Total number of bytes                 = 2335

Average number of records per group   = 4.0
Standard deviation from average       = 1.0
Average number of bytes per group     = 778.3
Standard deviation from average       = 286.2

Average number of bytes in a record   = 194.6
Average number of bytes in record ID  = 4.3
Standard deviation from average       = 42.3
Minimum number of bytes in a record   = 113
Maximum number of bytes in a record   = 270

Minimum number of fields in a record  = 66
Maximum number of fields in a record  = 80
Average number of fields per record   = 72.7
Standard deviation from average       = 6.5
The actual file size in bytes         = 8192.

Yes, parse for the description. However, you should check the database version first.

:version
Module Name         Version   Licensed
UniData RDBMS............ 7.1     Yes

That way if the file.stat data changes, you could call alternate routines.
Note: The file.stat output data has been static for sometime and is unlikely to change.

:file.stat TEST

File name                             = TEST
Number of groups in file (modulo)     = 3
Static hashing, hash type             = 0
Block size                            = 2048
Number of records                     = 12
Total number of bytes                 = 2335

Average number of records per group   = 4.0
Standard deviation from average       = 1.0
Average number of bytes per group     = 778.3
Standard deviation from average       = 286.2

Average number of bytes in a record   = 194.6
Average number of bytes in record ID  = 4.3
Standard deviation from average       = 42.3
Minimum number of bytes in a record   = 113
Maximum number of bytes in a record   = 270

Minimum number of fields in a record  = 66
Maximum number of fields in a record  = 80
Average number of fields per record   = 72.7
Standard deviation from average       = 6.5
The actual file size in bytes         = 8192.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文