473,411 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Database Access using pyodbc. I've a problem

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.

Jun 16 '07 #1
3 6150
On Jun 16, 5:35 am, Rajendran <raje...@gmail.comwrote:
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...mmon.html#user and
http://httpd.apache.org/docs/2.2/mod...uexecusergroup
Robert Brewer
System Architect
Amor Ministries
fu******@amor.org

Jun 16 '07 #2
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

Jun 17 '07 #3
-----Original Message-----
From: py******************************************@pytho n.org
[mailto:py***************************************** *@python.org] On
Behalf Of Rajendran
Sent: Sunday, June 17, 2007 3:06 AM
To: py*********@python.org
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
Jun 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: timw.google | last post by:
I just downloaded the pyodbc source to try and install on my Linux FC3 box. I see that there is a setup.py file, but when I try to do a 'python setup.py build' (or just 'python setup.py') I get ...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
8
by: king kikapu | last post by:
Hi to all, is there a way to use an RDBMS (in my case, SQL Server) from Python by using some built-in module of the language (v. 2.5) and through ODBC ?? I saw some samples that use statements...
2
by: Hitesh | last post by:
Hi currently I am using DNS and ODBC to connect to MS SQL database. Is there any other non-dns way to connect? If I want to run my script from different server I first have to create the DNS in...
0
by: timw.google | last post by:
How do I get a list of datasources with pyodbc? I know that with mx.ODBC.Windows I can use the DataSources method to get a dictionay containing the datasources. Is there a similar way to do this...
2
by: Joe Salmeri | last post by:
I believe this bug is also related to the other problem I just reported. OS = Windows XP SP2 DB = Microsoft Access XP PROBLEM: When you use + (or &) to concatenation columns together and...
4
by: coldpizza | last post by:
Hi, I want to run a database query and then display the first 10 records on a web page. Then I want to be able to click the 'Next' link on the page to show the next 10 records, and so on. My...
0
by: john.goodleaf | last post by:
I've just built pyodbc 2.0.58 against freetds and unixodbc. When I attempt to invoke it, either from the test script or from the interpreter, I get: ImportError:...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.