[DB-SIG] Examples on how to use mxODBC?
Andy Todd
andy47 at halfcooked.com
Fri Oct 24 04:14:42 EDT 2003
M.-A. Lemburg wrote:
> Goldthwaite, Joe wrote:
>
>> Hello again,
>>
>> I was using a jgoldtest at bar-s.com email address since that is what is
>> configured on my python development machine. I forgot that bar-s has a
>> device that appends an annoying "Property of Bar-S Foods.." message at
>> the
>> end of all outgoing email. To get around it, I had to subscribe to a
>> service that allows SSL connections. What a pain.
>>
>> Thanks for the responses from Marc-Andre and Andy Todd. Between the
>> two of
>> you, I got it working. I've actually done a lot of reading. I've gone
>> through the Marc's links and the mxODBC manual (which I see has your
>> Marc's
>> name in the front :)). I've also got The Python Cookbook, Programming
>> Python, Learning Python, Python in a Nutshell, and the Python How To
>> Program
>> on-line training course. With all that, I'm pretty sure I know
>> exactly how
>> it's supposed to work. I know I need to create a connection object
>> with the
>> right parameters. I just couldn't seem to come up with a combination that
>> works. I had tried this;
>>
>> from mx import ODBC
>> connection = ODBC.Connect("BarsFinRpts")
>>
>> And a large number of variations but I couldn't find the object that owns
>> the connect method. Andy Todd provided the last piece;
>>
>> connection = ODBC.Windows.connect("BarsFinRpts")
>>
>> That did it. I was missing the Windows object between the ODBC and the
>> connect(). I knew it was simple. How are you supposed to find this
>> sort of
>> thing? I've gotten used to Visual Studio where you type object. and
>> get a
>> list of the properties and methods. Does Python have anything similar?
>
>
> Most Python IDEs do, but Windows in this case is a sub-package of
> the mx.ODBC package. It is not easily possible to scan for submodules
> or -packages in Python due to the many ways this can be done.
>
> The fact that the above works is due to the LazyModule object
> we use in mx.ODBC.__init__. Normally, you'd have to write:
>
> from mx.ODBC.Windows import DriverConnect
> conn = DriverConnect('DSN=mydsn;UID=myuid;PWD=mypwd')
>
> to get a connection to the database.
>
>> I've tried using the dir() function to explore the namespace but when
>> I try
>> dir('ODBC') I don't see the Windows object listed. I've also tried
>> the Wing
>> IDE but it just seems to show the generic namespace not the specific
>> methods
>> of the current object. It also doesn't seem to have any function help
>> available.
>>
>> At this point, figuring out HOW to figure out this sort of problem would
>> probably be the best help.
>
>
> The mxODBC documentation talks about subpackages and also gives
> an example, but you're right, it's mostly focussed on describing
> the details and is missing a tutorial style introduction.
>
>> Thanks again! I really appreciate the time you guys took to reply.
>
>
Go and get the Python for Windows extensions
(http://sourceforge.net/projects/pywin32/) they include the Pythonwin
editor/ide. This gives tooltips and command completion as you are used
to in Visual studio.
If you want a Python interpreter with nice GUI introspection tools then
I can't praise Patrick O'Brien's Py tools highly enough
(http://www.orbtech.com/www/PyManual.html). They are shipped as part of
the wxPython GUI toolkit (http://www.wxpython.org/).
Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
More information about the DB-SIG
mailing list