[XML-SIG] How to convert my data in database to XML

Lloyd Kvam python at venix.com
Thu May 5 23:59:28 CEST 2005

Your SQL database will support SQL commands like DESCRIBE TABLE.  For
MySQL I have used:
    cursor.execute( 'SHOW COLUMNS FROM %s' % tablename)
    for row in cursor.fetchall():
        fname = row[0]		# my live code also saved the type info

to build a dictionary of field names and types for a table to control

I presume your XML is supposed to look something like:


If that description fits what you are trying to do, then you should not
have too much difficulty coding up the pieces.  This glosses over
difficulties with XML character rules in tags and elements, encoding
binary data, etc.

On Thu, 2005-05-05 at 15:09 -0600, Uche Ogbuji wrote:
> On Wed, 2005-05-04 at 03:03 -0400, Kun Xi wrote:
> > Hello. I have the same question:
> > The data is store in Sql database, but the database schema is determined
> > in the runtime. I need to generate the xml file without knowing the
> > table structure, sound insane? Is there any tool, framework that could
> > read the configuration file and serialize the xml file from/to the
> > database ?
> > 
> > I don't need the o/r mapping, I just need a filter between the xml and
> > database.
> And by "configuration file", I assume you mean SQL DDL.
> This is the sort of thing that most DBMS vendors sell as features or
> add-ons.  Many OSS projects have such tools as well.  I don't know of
> anything general purpose in Python for this.

Lloyd Kvam
Venix Corp

More information about the XML-SIG mailing list