Mailing List Archive

Non-ODBC MS Sql Connect
How to do I make a non-odbc connection to a MS SQL Server?

Am running Python Windows NT/IIS.

Thanks,
Non-ODBC MS Sql Connect [ In reply to ]
You can always use ADO from Python on NT.

Quick example:
import win32com.client
import win32com.client.makepy
import win32com.client.genpy
import win32com.client.gencache
adolib = win32com.client.gencache.EnsureModule(
'{00000200-0000-0010-8000-00AA006D2EA4}', # TypeLib GUID for ADO
win32con.LANG_NEUTRAL, # LCID
2, # Major version #
0, # Minor version #
win32com.client.genpy.GeneratorProgress()) # Silent progress
indicator.
# ALL loaded typelibrary constants...
k = win32com.client.constants
cxnSQLServer = adolib.Connection()
cxnSQLServer.CursorLocation = k.adUseNone
cxnSQLServer.Provider = "SQLOLEDB"
cxnSQLServer.Open("Server=MachineName;Database=master;UID=user;PWD=apple")

rs = adolib.Recordset()
rs.Open("select * from sysobjects", cxnSQLServer, k.adOpenForwardOnly,
k.adLockReadOnly)
# etc.....


Bill




> -----Original Message-----
> From: Roberts, Robert J [mailto:robert_j_roberts@rl.gov]
> Sent: Thursday, July 22, 1999 5:33 PM
> To: python-list@cwi.nl
> Subject: Non-ODBC MS Sql Connect
>
>
> How to do I make a non-odbc connection to a MS SQL Server?
>
> Am running Python Windows NT/IIS.
>
> Thanks,
>
>
Non-ODBC MS Sql Connect [ In reply to ]
RJR,

1. Grab mysql-python151-win32.zip from /pub/crew/jbauer
via anon ftp at starship.python.net.

2. Put libmySQL.dll somewhere in your PATH, and put MySQL.pyd
somewhere Python will find it -- e.g. the same directory
python.exe is possible.

3. It works okay with 1.5.1 or higher. For more info
about the MySQL library, download the source from the
Contrib area at python.org.

>>> import MySQL
>>> DBH = MySQL.connect('myhost','mydatabase','mypassword')
>>> DBH.listdbs()

[['mydb1'], ['mysql'], ['test']]

Best regards,

Jeff Bauer
Rubicon, Inc.

>> How to do I make a non-odbc connection to a MS SQL Server?
>> Am running Python Windows NT/IIS.
Non-ODBC MS Sql Connect [ In reply to ]
"Roberts, Robert J" wrote:
> How to do I make a non-odbc connection to a MS SQL Server?
> Am running Python Windows NT/IIS.

Argh! Your post said MS SQL, but my brain saw MySQL.
Sorry for the previous response.

-Jeff
Non-ODBC MS Sql Connect [ In reply to ]
Thanks for the quick reply.

I tried it, however, and get:

File "C:\Web\http\isearch\testNonOdbc01.py", line 44, in Main
import win32com.client
File "C:\Program Files\Python\win32com\client\__init__.py", line 8, in ?
import dynamic, CLSIDToClass, gencache, pythoncom
File "C:\Program Files\Python\win32com\client\dynamic.py", line 22, in ?
import pythoncom
ImportError: No module named pythoncom

I have pythoncom documentation in: c:\python\win32com\html

...but no pythoncom.py

I re-downloaded the latest win32all and reinstalled, but still no
pythoncom.py.

Am I being brain dead or am I missing something?

Bill Tutt wrote:

> You can always use ADO from Python on NT.
>
> Quick example:
> import win32com.client
> import win32com.client.makepy
> import win32com.client.genpy
> import win32com.client.gencache
> adolib = win32com.client.gencache.EnsureModule(
> '{00000200-0000-0010-8000-00AA006D2EA4}', # TypeLib GUID for ADO
> win32con.LANG_NEUTRAL, # LCID
> 2, # Major version #
> 0, # Minor version #
> win32com.client.genpy.GeneratorProgress()) # Silent progress
> indicator.
> # ALL loaded typelibrary constants...
> k = win32com.client.constants
> cxnSQLServer = adolib.Connection()
> cxnSQLServer.CursorLocation = k.adUseNone
> cxnSQLServer.Provider = "SQLOLEDB"
> cxnSQLServer.Open("Server=MachineName;Database=master;UID=user;PWD=apple")
>
> rs = adolib.Recordset()
> rs.Open("select * from sysobjects", cxnSQLServer, k.adOpenForwardOnly,
> k.adLockReadOnly)
> # etc.....
>
> Bill
>
> > -----Original Message-----
> > From: Roberts, Robert J [mailto:robert_j_roberts@rl.gov]
> > Sent: Thursday, July 22, 1999 5:33 PM
> > To: python-list@cwi.nl
> > Subject: Non-ODBC MS Sql Connect
> >
> >
> > How to do I make a non-odbc connection to a MS SQL Server?
> >
> > Am running Python Windows NT/IIS.
> >
> > Thanks,
> >
> >