Using .UDL files with Python

waldekO osuchw at ecn.ab.ca
Fri Jul 5 11:36:31 EDT 2002


"Opus" <opus at value.net> wrote in message news:<mailman.1025770508.26513.python-list at python.org>...
> Is there anything for Python that allows the usage of a .UDL to describe the 
> connection to a database?

The .udl file is really a text file.  You could open it from Python
using open('some_udl.uld').

>>> udl = open('c:/sample.udl')
>>> connstring = udl.readlines()[2]
>>> connstring
'\x00P\x00r\x00o\x00v\x00i\x00d\x00e\x00r\x00=\x00M\x00S\x00D\x00A\x00O\x00R\x00A\x00.\x001\x00;\x00U\x00s\x00e\x00r\x00
\x00I\x00D\x00=\x00s\x00u\x00p\x00p\x00o\x00r\x00t\x00;\x00D\x00a\x00t\x00a\x00
\x00S\x00o\x00u\x00r\x00c\x00e\x00=\x00m\x00f\x00i\x00s\x00;\x00P\x00e\x00r\x00s\x00i\x00s\x00t\x00
\x00S\x00e\x00c\x00u\x00r\x00i\x00t\x00y\x00
\x00I\x00n\x00f\x00o\x00=\x00F\x00a\x00l\x00s\x00e\x00\r\x00\n'
>>> connstring = connstring.replace('\x00','')
>>> connstring
'Provider=MSDAORA.1;User ID=support;Data Source=mfis;Persist Security
Info=False\r\n'
>>> 
Each character is padded with 0 but replace() takes care of that.

waldekO



More information about the Python-list mailing list