473,804 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6192
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.o rg

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.d ll"
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************* *************** **************@ python.org
[mailto:py****** *************** *************** ******@python.o rg] On
Behalf Of Rajendran
Sent: Sunday, June 17, 2007 3:06 AM
To: py*********@pyt hon.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.d ll"
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
4051
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 Traceback (most recent call last): File "setup.py", line 27, in ? revision = latest_revision('.') File "setup.py", line 25, in latest_revision return int(output) ValueError: invalid literal for int(): exported
18
9157
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 page "How to: Connect to Data in an Access Database"
8
1770
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 like "import dbi" or "import odbc" but neither modules (dbi, odbc) are present on my system... Any hint(s) ?? Thanks in advance
2
8863
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 win2k3. Thank you, hj
0
1372
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 with pyodbc? Thanks in advance.
2
5331
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 the columns are of type text and the combined length exceed 255 this causes pyodbc to fail and python to crash.
4
3037
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 question is how to implement paging, i.e. the 'Next/Prev' NN records without reestablishing a database connection every time I click Next/Prev? Is it at all possible with cgi/mod_python?
0
1374
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: build/lib.linux-x86_64-2.5/pyodbc.so: undefined symbol: PyUnicodeUCS2_Resize I'm not quite sure how to go about troubleshooting this. More info: Build is on opensuse 11.0, intel x86_64 from Python 2.5.2. I've also
1
3864
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 parser and dbi/ odbc for my db connection. To fix problems with unicode I built a work-around by mapping unicode characters to equivalent ascii characters and then encoding everything to ascii. That allowed me to build the application and debug...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.