Database Access using pyodbc. I've a problem

Discussion in 'Python' started by Rajendran, Jun 16, 2007.

  1. Rajendran

    Rajendran Guest

    Hi all,

    I've installed pyodbc module to access my database (MS Access). I've
    setup a User level DSN to the database.mdb file. When I run my python
    code in the command prompt it is retrieving the database contents and
    displaying it (HTML output).
    But when I run that python from webserver (http://localhost/cgi-bin/
    database.py) there comes an entry in the error log of Apache server
    that says:

    [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] Premature end of
    script headers: database.py
    [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] Traceback (most
    recent call last):\r
    [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] File "C:/
    Apache Software Foundation/Apache2.2/cgi-bin/database.py", line 10, in
    <module>\r
    [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] cnxn =
    pyodbc.connect('DSN=Emp')\r
    [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] pyodbc.Error:
    ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] The
    Microsoft Jet database engine cannot open the file '(unknown)'. It is
    already opened exclusively by another user, or you need permission to
    view its data. (-1032); [HY000] [Microsoft][ODBC Microsoft Access
    Driver] The Microsoft Jet database engine cannot open the file
    '(unknown)'. It is already opened exclusively by another user, or you
    need permission to view its data. (-1032)")\r

    Even though the MS Access file is closed.

    I've no administrator rights and I've installed all these as a normal
    windows user.

    I don't have problem when I write a similar kind of code in PHP. What
    could be the reason? Is it because I don't have administrator rights?
    or something else?
    Please help me out.
     
    Rajendran, Jun 16, 2007
    #1
    1. Advertising

  2. Rajendran

    fumanchu Guest

    On Jun 16, 5:35 am, Rajendran <> wrote:
    > Hi all,
    >
    > I've installed pyodbc module to access my database (MS Access). I've
    > setup a User level DSN to the database.mdb file. When I run my python
    > code in the command prompt it is retrieving the database contents and
    > displaying it (HTML output).
    > But when I run that python from webserver (http://localhost/cgi-bin/
    > database.py) there comes an entry in the error log of Apache server
    > that says:
    >
    > [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] Premature end of
    > script headers: database.py
    > [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] Traceback (most
    > recent call last):\r
    > [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] File "C:/
    > Apache Software Foundation/Apache2.2/cgi-bin/database.py", line 10, in
    > <module>\r
    > [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] cnxn =
    > pyodbc.connect('DSN=Emp')\r
    > [Sat Jun 16 17:55:57 2007] [error] [client 127.0.0.1] pyodbc.Error:
    > ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] The
    > Microsoft Jet database engine cannot open the file '(unknown)'. It is
    > already opened exclusively by another user, or you need permission to
    > view its data. (-1032); [HY000] [Microsoft][ODBC Microsoft Access
    > Driver] The Microsoft Jet database engine cannot open the file
    > '(unknown)'. It is already opened exclusively by another user, or you
    > need permission to view its data. (-1032)")\r
    >
    > Even though the MS Access file is closed.
    >
    > I've no administrator rights and I've installed all these as a normal
    > windows user.
    >
    > I don't have problem when I write a similar kind of code in PHP. What
    > could be the reason? Is it because I don't have administrator rights?
    > or something else?
    > Please help me out.


    Looks like a permissions problem at first glance. See
    http://httpd.apache.org/docs/2.2/mod/mpm_common.html#user and
    http://httpd.apache.org/docs/2.2/mod/mod_suexec.html#suexecusergroup


    Robert Brewer
    System Architect
    Amor Ministries
     
    fumanchu, Jun 16, 2007
    #2
    1. Advertising

  3. Rajendran

    Rajendran Guest

    Hi Robert,
    Thanks for your response.
    The problem I've mentioned comes up only with the Python but not with
    the PHP. Is it because PHP has been integrated with Apache and Python
    isn't? I mean, we have included these

    # For PHP 5 do something like this:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddType application/x-httpd-php .php

    # configure the path to php.ini
    PHPIniDir "C:/php"


    lines in the httpd.conf for Apache to understand PHP and no
    corresponding lines for Python?

    Does this make Apache to run PHP with the permissions same as user?

    Don't we have this option for Python?

    Thanks in Advance.
    Rajen
     
    Rajendran, Jun 17, 2007
    #3
  4. > -----Original Message-----
    > From: python-list-bounces+dphillips=
    > [mailto:python-list-bounces+dphillips=] On
    > Behalf Of Rajendran
    > Sent: Sunday, June 17, 2007 3:06 AM
    > To:
    > Subject: Re: Database Access using pyodbc. I've a problem
    >
    > Hi Robert,
    > Thanks for your response.
    > The problem I've mentioned comes up only with the Python but not with
    > the PHP. Is it because PHP has been integrated with Apache and Python
    > isn't? I mean, we have included these
    >
    > # For PHP 5 do something like this:
    > LoadModule php5_module "c:/php/php5apache2_2.dll"
    > AddType application/x-httpd-php .php
    >
    > # configure the path to php.ini
    > PHPIniDir "C:/php"
    >
    >
    > lines in the httpd.conf for Apache to understand PHP and no
    > corresponding lines for Python?
    >
    > Does this make Apache to run PHP with the permissions same as user?


    There are two user execution settings in Apache. The first (User) tells
    Apache which user to run as. The second (SuExec User) tells Apache
    which user to run CGI files as. These can (and should) be handled
    differently in a production system.

    I'm not familiar with how apache handles these functions in a Windows
    environment, but the references in a prior answer to this thread should
    help you out.

    -Doug
     
    Doug Phillips, Jun 17, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Salmeri

    pyodbc data corruption problem

    Joe Salmeri, May 19, 2007, in forum: Python
    Replies:
    3
    Views:
    380
    Joe Salmeri
    May 24, 2007
  2. john.goodleaf

    Problem with pyodbc, Python?

    john.goodleaf, Aug 1, 2008, in forum: Python
    Replies:
    0
    Views:
    313
    john.goodleaf
    Aug 1, 2008
  3. Frank Millman

    pyodbc - problem passing None as parameter

    Frank Millman, Oct 22, 2009, in forum: Python
    Replies:
    0
    Views:
    287
    Frank Millman
    Oct 22, 2009
  4. Tim Golden
    Replies:
    0
    Views:
    659
    Tim Golden
    Oct 22, 2009
  5. Tim Golden
    Replies:
    0
    Views:
    623
    Tim Golden
    Oct 23, 2009
Loading...

Share This Page