1

I'm working with a management that export the archive in .fdb bytes, the fdb file is the file used by Firebird. Now I have to create a parser with Python that gets the archive and parse all the archive with the Firebird's specifications so that I'll could create my json/xml/ecc with the data obtained by the archive.

Here the link with the specifications of the files

https://firebirdsql.org/manual/fbint-structure.html

Does anyone have experience with creating parsers and can they direct me?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • why would you need it? Next version of Firebird would change ODS, at large or in some obscure little detail, and you would have to update your parser again and again, in a never ending wack-a-mole fashion. Take Firebird Embedded DLL and use it from your python code. You can also take Firebird C++ sources and work from them. Either re-writing them in Python or trying to make a low-level access DLL out of them and then using it from Python – Arioch 'The Mar 05 '20 at 15:15
  • you can also find FBExport utility on SourceForge, why not using FBExport+Firebird to create those jsons ? – Arioch 'The Mar 05 '20 at 15:16
  • I understand what you mean, but it is not my choice, the archive conversion is part of a larger database integration project of my start up, they want my program to take the archive at present, decode it and send it to the our database the data of interest ... without any customer interaction .... here is the problem, otherwise I would have worked with simple exels – Eric Pavone Mar 05 '20 at 15:20
  • You do not need "customer interaction" to call external DLL or EXE files. Just do it without asking customers. Notice, that Firebird 2.5 will work with ODS versions back to Interbase 5 of late 1990-s. But Firebird 3.0 intentionally dropped the ball and would only work with it's own ODS 12. And chances are coming Firebird 4 also would exclusively work with its own ODS version and no more cross-version compatibilities... Frankly, if you totally need parsing - i would ask them to send .FBK files instead of .FDB and then convert `gbak` code to Python. FBK should be more suited for one-way parsing – Arioch 'The Mar 05 '20 at 15:24

1 Answers1

2

You don't need to create a parser. A .fdb file is - assuming the normal naming conventions for Firebird - a Firebird database file. To read it, you need a Firebird server (or Firebird embedded) to open the database, then you can query the database using SQL.

From Python you can use the libraries fdb or pyfirebirdsql to connect to a Firebird server to access the database file. The fdb library uses the native Firebird bindings, so it should also be able to use Firebird embedded, while pyfirebirdsql can only connect to a Firebird server.

In short, don't try to write a parser, when one already exists: Firebird, a very advanced parser that allows you to use the full power of SQL to access the data.

Be aware though that Firebird database files are tied to a Firebird version, so you need to use the right Firebird version to be able to access the file.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197