views:

218

answers:

1

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.

+2  A: 

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.
Noah