473,320 Members | 2,133 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,320 software developers and data experts.

error: db type could not be determined

why does the following error occur?

def quit_time():
data_file = shelve.open("data.dat", "c")
data_file["quit_time"] = datetime.datetime.today()
print data_file["quit_time"]
raw_input("enter")
Traceback (most recent call last):
File "D:\a\TEXT\Py\going_over\going_over.py", line 192, in -toplevel-
main()
File "D:\a\TEXT\Py\going_over\going_over.py", line 190, in main
quit_time()
File "D:\a\TEXT\Py\going_over\going_over.py", line 156, in quit_time
data_file = shelve.open("data.dat", "c")
File "D:\A\UTILITIES\PYTHON\PYTHON23J\lib\shelve.py ", line 231, in
open
return DbfilenameShelf(filename, flag, protocol, writeback, binary)
File "D:\A\UTILITIES\PYTHON\PYTHON23J\lib\shelve.py ", line 212, in
__init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol,
writeback, binary)
File "D:\A\UTILITIES\PYTHON\PYTHON23J\lib\anydbm.py ", line 80, in
open
raise error, "db type could not be determined"
error: db type could not be determined

Jul 18 '05 #1
1 5872

ne********@myrealbox.com wrote:
why does the following error occur?


I don't know; I've never used the shelve module. Let's see what as two
utter n00bz we can find out. Let's check out where it clagged:
lib\anydbm.py, line 80, in open ...

Hmm, reading backwards a little, looks like it called whichdb.whichdb
to nut out what sort of database it was, and whichdb reported back that
it was an existing file, of unknown type. Flicking through whichdb.py
confirms this.

Let's see if we can reproduce that:

=== step 1: file doesn't exist ===
C:\junk>c:\python23\python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
import shelve
df = shelve.open('mydata.dat', 'c')
^Z
C:\junk>dir mydata.dat
[snip]
26/02/2005 08:40p 24,576 mydata.dat

=== looks like file created OK ==

C:\junk>del mydata.dat
C:\junk>copy con mydata.dat
any old codswallop
^Z
1 file(s) copied.

=== OK, now mydata.dat is trash.

C:\junk>c:\python23\python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information. import shelve
df = shelve.open('mydata.dat', 'c') Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\python23\lib\shelve.py", line 231, in open
return DbfilenameShelf(filename, flag, protocol, writeback, binary)
File "c:\python23\lib\shelve.py", line 212, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol,
writeback, binary)
File "c:\python23\lib\anydbm.py", line 80, in open
raise error, "db type could not be determined"
anydbm.error: db type could not be determined


Uh-huh.

By the way, it's probably not a good idea to use a ".dat" extension;
evidently (read whichdb.py for the gory details) some of the dbms add
an extension to the supplied name. One of them uses ".dat". Could
become a source of confusion.

Take a hint: they say "Google is your friend", but better still is the
source in lib\*.py -- it's quite legible, you don't need an Internet
connection, and there sure ain't no ads in the margin. And don't just
open it in emergencies: pick a module that covers a topic that
interests you and just read it. You'll see good coding style, good ways
of doing things, wise utterances by the timbot, ...

HTH,
John

Jul 18 '05 #2

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

Similar topics

11
by: ColdCanuck | last post by:
Greetings! I am VERY new to DB2 but not Orable, Sybase and SQL Server. I am trying to call a stored procedure via VB 6 and ADO/OLEDB. But when I try to execute
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
33
by: nkhan | last post by:
Need some help on this please: EECE1207 Spring 2005 Computer Assignment # 1 Due Wednesday, March 23rd The file ‘grades.txt’, as shown below, contains the results of a true-false exam...
3
by: Benedikt Weber | last post by:
I found the following compiler error with Microsoft Visual C++ .NET. I use different functions with return types determined by a Traits class. Function g() below works ok, but when I put the two...
4
by: MSNews | last post by:
I get the following exception when calling Dns.GetHostName (from C#): An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll Additional information: An...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: Olav | last post by:
Hi all, I can not install CF 2.0 SP 1 on an Symbol PPT8800 running WinCE 4.2. The Install-Log say's cgacutil.exe failed with exit-code 80000004 and I get a messagebox indicating a support-Info...
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done...
13
by: 7stud | last post by:
test1.py: -------------------- import shelve s = shelve.open("/Users/me/2testing/dir1/aaa.txt") s = "red" s.close() --------output:------ $ python test1.py
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.