error: db type could not be determined

Discussion in 'Python' started by neutrinman@myrealbox.com, Feb 26, 2005.

  1. Guest

    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
    , Feb 26, 2005
    #1
    1. Advertising

  2. John Machin Guest

    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
    John Machin, Feb 26, 2005
    #2
    1. Advertising

  3. Guest

    Thank you for your reply, Jhon.
    It was useful advice.

    > 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, ...


    I am new to programing so I was wasting a lot of time to fix bug, only
    struggling with my code where an error has occured then read throug an
    book at hand. I didn't think of such an approch to solve problems and
    read error messages.

    Thank you again very much for the imformative advice.
    , Feb 27, 2005
    #3
    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. have_a_question_!
    Replies:
    1
    Views:
    702
    Mark McDougall
    Nov 21, 2005
  2. Michael Hogan
    Replies:
    2
    Views:
    297
    Michael Hogan
    Feb 20, 2004
  3. Simon Harris
    Replies:
    0
    Views:
    6,362
    Simon Harris
    May 10, 2005
  4. krabhi
    Replies:
    1
    Views:
    9,290
    Marco Meschieri
    Aug 9, 2006
  5. Joe Curry

    Invalid URI: The format of the URI could not be determined.

    Joe Curry, Oct 8, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    335
    Joe Curry
    Oct 8, 2003
Loading...

Share This Page