SQL parsing suggestions?

Started by Vance Maverickover 19 years ago3 messagesgeneral
Jump to latest
#1Vance Maverick
vmaverick@pgp.com

I have a PostgreSQL schema definition. I'd like to be able to use it as
the basis for code generation in a software build process --
specifically, I want to generate Java enums corresponding to the table
definitions. However, it would be inconvenient to have to connect to a
running database during the build.

What approach would people suggest? I'm open to working in any
language. Are there PostgreSQL parsing tools out there -- perhaps, the
parser module itself from the database server? Or something from the
JDBC driver, or the perl or PHP interfaces? Or does anyone have
experience with other SQL parsers that can handle all the syntax of
PostgreSQL files?

Vance

#2John DeSoi
desoi@pgedit.com
In reply to: Vance Maverick (#1)
Re: SQL parsing suggestions?

On Jul 11, 2006, at 11:49 AM, Vance Maverick wrote:

I have a PostgreSQL schema definition. I'd like to be able to use
it as
the basis for code generation in a software build process --
specifically, I want to generate Java enums corresponding to the table
definitions. However, it would be inconvenient to have to connect
to a
running database during the build.

What approach would people suggest?

I would suggest connect to a running database during the build :)

Maybe if you don't want to connect for every build, you could create
a procedure that runs as part of any schema update to the database.
This procedure would generate a simple, easily-to-parse file of the
schema information you need for your build. Building this file from
the information schema when you are connected to the database should
be an easy task in comparison to creating a parser.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

#3Merlin Moncure
mmoncure@gmail.com
In reply to: Vance Maverick (#1)
Re: SQL parsing suggestions?

On 7/11/06, Vance Maverick <vmaverick@pgp.com> wrote:

I have a PostgreSQL schema definition. I'd like to be able to use it as
the basis for code generation in a software build process --
specifically, I want to generate Java enums corresponding to the table
definitions. However, it would be inconvenient to have to connect to a
running database during the build.

What approach would people suggest? I'm open to working in any
language. Are there PostgreSQL parsing tools out there -- perhaps, the
parser module itself from the database server? Or something from the
JDBC driver, or the perl or PHP interfaces? Or does anyone have
experience with other SQL parsers that can handle all the syntax of
PostgreSQL files?

I would load the schema definition into a postgresql server and then
query information_shcema to introduce formatting :)

In a previous project, I was able go generate COBOL fd files quite
easily from postgresql tables/'views via simple querying off of
information schema.

merlin