Year of Python (YOP) – Week Thirty One


Hello Reader!

This week I’ve started to go back to my Year of Python script for week 22, and parse out some of the ESE DB Header information further.  I ended up writing two more functions that parse out the Database State Code and the Log Position.

Once again I have to credit Joachim Metz’s great work in analyzing the overall structure of this file type.  My hope is to have an overall script that will parse out these files when it’s all said and done.  But I know I have a ways to go yet (thankfully there’s still 21 weeks left in the year!).

What I decided to do this time around was to create a script that will parse these two items, instead of trying to explain where to replace lines of code from the original week 22 script.  My feeling is that starts to get confusing in keeping track of which line numbers to replace code into.  Plus if someone decides they want to use the code for other programs, it’s easier to pull the code out since it can work on it’s own.

The first function parses out the Database state, which should be self explanatory.  All I’m doing here is putting the possible state codes into an array, then we just read in the four byte value at file offset 52, and finally return the appropriate code for that value.

The second function parses out the Log Position, which is a JET_LGPOS structure that according to MSDN:

“…holds data that is internal to the logging mechanism of the database engine”

You can find out more about this structure at the MSDN link.  For now I’m just providing the values.

The to wrap it all up, we just print out the values from the functions…

Until next week!


No Responses Yet to “Year of Python (YOP) – Week Thirty One”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: