[Zope] Database Adapter For Windows DB

Baiju M mbaiju at zeomega.net
Wed Apr 15 13:00:53 EDT 2009


On Tue, Apr 14, 2009 at 1:22 AM, Andreas Jung <lists at zopyx.com> wrote:
>
> On 13.04.2009 23:33 Uhr, Bobby wrote:
>> Hi,
>>

>> I'm running Zope on a Linux box and need to connect to a Window's SQL
>> Server machine. Which Zope's DB Adapter should I use? Thanks.
>
> mxODBC

Here is a free (as in freedom) software created by Andreas Jung:

  http://pypi.python.org/pypi/z3c.sqlalchemy

You will be required to install:

1. "SQLAlchemy" (Object Relational Mapper)
    http://www.sqlalchemy.org

    More details about using M$ SQL Server with SQLAlchemy:
      http://www.sqlalchemy.org/docs/05/reference/dialects/mssql.html

2. "pyodbc" (Python DB API 2.0 compatible module)
    http://pyodbc.sourceforge.net/

3. "FreeTDS" (ODBC Driver for M$ SQL Server)
    http://www.freetds.org/

4. "unixODBC" (ODBC Manager)
    http://www.unixodbc.org/

Well, it's all very easy to setup.  More detailed steps:

1. Install Python

2. Install unixODBC

   While configuring unixODBC use "--disable-gui" option::

     $ ./configure --prefix=/path/to/usr --disable-gui

3. Install FreeTDS

     While installing FreeTDS use these options::

       $ ./configure --prefix=/path/to/usr --with-tdsver=8.0
--with-unixodbc=/path/to/usr/

4. Configure "odbc.ini"

   In the "/path/to/usr/etc/odbc.ini" file, add something like
   this::

     [db_connections]
     first_db = MS SQL Server

     [first_db]
     Driver = FreeTDS
     Description = My First Database
     Trace = No
     Server = 192.168.1.18
     Port = 1433
     Database = test_database

5. Configure "odbcinst.ini"

     [FreeTDS]
     Description = v0.68 with protocol v8.0
     Driver = /path/to/usr/lib/libtdsodbc.so
     UsageCount = 1

5. Set environment variables

     ODBCINI="/path/to/usr/etc/odbc.ini"
     ODBCINSTINI="/path/to/usr/etc/odbcinst.ini"
     LD_LIBRARY_PATH="/path/to/usr/lib"
     export ODBCINI ODBCINSTINI LD_LIBRARY_PATH

   To test your connection:

     /path/to/usr/bin/isql first_db username password

6. Isstall "pyodbc"

   (Refer: http://www.easysoft.com/developer/languages/python/pyodbc.html)

   Here is some relevant text:

   To build pyodbc against unixODBC, you need to tell the compiler
   and linker where to find the unixODBC include files and
   libraries. To do this, open setup.py in a text editor and find
   these lines:

     extra_compile_args = None
     extra_link_args    = None

   Edit the second line so that it looks likes this:

     extra_compile_args = None
     extra_link_args    = ['-L/path/to/usr/lib']

   Find this line:

     extra_compile_args = ['-Wno-write-strings']

   Edit the line so that it looks like this:

     extra_compile_args = ['-Wno-write-strings', '-I/path/to/usr/include']

7. Install SQLAlchemy
8. Install z3c.sqlalchemy


If you succeed with this, can you create a tutorial about how to do
it ? :)

Regards,
Baiju M


More information about the Zope mailing list