What is the "state of the art" with respect to Python on Windows?
April 2, 2008 7:18 AM   Subscribe

What is the "state of the art" with respect to Python on Windows for Active Directory administration and interfacing with MS-SQL 2000/2005/2008?

I have a copy of Python: Programming on Win32, which is nice, but is also eight years old. I've seen a lot of modules and scripts out there (fewer overlapping choices than Perl, which is one of the reasons I'm moving away from Perl). However, I don't have a good sense of what Python professionals are actually using to accomplish these tasks: modules? some kind of COM voodoo? giving up and using VBScript?

On the Active Directory side, I'm looking to do the sorts of tasks one finds in the Active Directory Cookbook, often in a larger structured program rather than a handful of messy little scripts without much error checking. On the SQL side, I'm pretty comfortable using ODBC, up to about the point where I can actually flail about and use cursors in a reasonable manner. Python seems to have a lot of ODBC wrapper scripts, some pages say that the ODBC module itself is "old."

I'd rather just learn something current that might have some ongoing development (or at least a community of support), instead of finding something ancient that works but will never grow. Where can I find the invariable Windows gotchyas?

Windows-haters and related flames to /dev/nu— (wait, does Windows have a bitbucket? If it did, would it even be documented?) err, circular file. In the words of Hedwidg, "it's what I have to work with."
posted by adipocere to Computers & Internet (7 answers total)
 
Response by poster: Drat, Hedwig.
posted by adipocere at 7:22 AM on April 2, 2008


Umm - what about using IronPython and then getting access to the built-in libraries. Or potentially try Mono (I would think they have good LDAP support, and AD is sort of LDAP-compliant). Is it that you are trying to manage the Windows AD/SQL from a non-Windows environment? Because on Windows the .NET Framework SDK & IronPython are completely free... There are tons of sample code for how to use the .NET AD/data API's...

Worst-case scenario hook into the Win32 API's yourself and simply update the wrappers. Or find some other open-source project which has kept their wrappers up-to-date (Delphi/Pascal - Project JEDI, etc.).

(I would think the Windows bit-bucket would be the system paging file... ;-)
posted by jkaczor at 9:55 AM on April 2, 2008


Oops - I see you mentioned Python on Windows. Then I think your most supportable route would be IronPython via the .NET runtime and then accessing the .NET framework libraries.
posted by jkaczor at 10:02 AM on April 2, 2008


You can try this module.
posted by swapspace at 7:59 AM on April 3, 2008


IronPython + PowerShell = What you're looking for.
posted by togdon at 9:30 AM on April 7, 2008


Response by poster: So, for the future reference of anyone visiting, or in case I get a time machine, here goes:

For SQL: ActivePython (from ActiveState) comes with an odbc module. For documentation, use the web help. It's relatively simple. There is also a pyodbc module for the up and comers. It looks like it conforms somewhat to the DBI 2.0 spec for Python. I haven't touched it yet, but I hear good things about it.

As to Active Directory manipulation, the correct method is to use win32com and the .client.Dispatch to manipulate the Active Directory by using Win32 COM. Don't spend much time looking for Python-oriented code. Instead, look at how VBS users use Win32 objects, then adapt as necessary. Use dir() to examine the interfaces to these objects, as they will surprise you.
posted by adipocere at 12:59 PM on September 30, 2008


"Windows can has a bitbucket."

Windows NT/2000/XP/Vista/2008 still use MS-DOS for it's command shell. Back in the days of MS-DOS, there were some special filenames for talking to devices. LPT1: for the 24-pin "parallel" port, COM1: for the 9-pin "serial" port, CON: for standard output handle, and NUL: for discarding everything.

C:\> type C:\autoexec.bat >NUL:

This will do the nothing that you expected.
posted by Mozai at 7:38 AM on October 2, 2008


« Older Has my overactive imagination turned into anxiety?   |   How can I stop these people from copying my site? Newer »
This thread is closed to new comments.