pysqlite problem

Discussion in 'Python' started by bapolis@gmail.com, Mar 1, 2006.

  1. Guest

    Hello,

    I'm getting the following error:

    pysqlite2.dbapi2.OperationalError: no such table: tbl1

    Here's my code:

    from pysqlite2 import dbapi2 as sqlite
    con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
    cur = con.cursor()
    cur.execute("select * from tbl1")
    data = cursor.fetchall()
    for record in date:
    record[0], record[1]

    my installation versions:

    python 2.4.2
    pysqlite 2.0.7
    sqlite 3.3.4

    I checked to make sure I have a table called tbl1. I don't understand
    what's going on. Any ideas?
    , Mar 1, 2006
    #1
    1. Advertising

  2. Guest

    my bad. that was the wrong code, here is my code:

    from pysqlite2 import dbapi2 as sqlite
    con = sqlite.connect("ex1")
    cur = con.cursor()
    cur.execute("select * from tbl1")
    print cur.fetchall()
    , Mar 1, 2006
    #2
    1. Advertising

  3. looping Guest

    Is it the complete code ?

    If so then you have to create the table each time you connect to the
    DB.

    You use an in-memory DB (":memory:") so all the data of the DB is lost
    when you close the connection, including the schema of the DB.
    looping, Mar 1, 2006
    #3
  4. looping Guest

    OK, it's better.

    You use relative path to your file 'ex1', are you really sure that you
    open the right file and not creating another DB in another path ?

    Try to use absolute path (r'c:\temp\ex1').
    looping, Mar 1, 2006
    #4
  5. >>>>> bapolis <> writes:

    > con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)

    ^^^^^^^^^^

    Did you really intend this? Since you're opening a database in memory, you
    will have access to tbl1 only if you create the table after the connect.

    Ganesan

    --
    Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
    Web: http://employees.org/~rganesan | http://rganesan.blogspot.com
    Ganesan Rajagopal, Mar 1, 2006
    #5
  6. wrote:

    > I'm getting the following error:
    >
    > pysqlite2.dbapi2.OperationalError: no such table: tbl1
    >
    > Here's my code:
    >
    > from pysqlite2 import dbapi2 as sqlite
    > con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
    > cur = con.cursor()
    > cur.execute("select * from tbl1")
    > data = cursor.fetchall()
    > for record in date:
    > record[0], record[1]
    >
    > my installation versions:
    >
    > python 2.4.2
    > pysqlite 2.0.7
    > sqlite 3.3.4
    >
    > I checked to make sure I have a table called tbl1.


    where?

    > I don't understand what's going on. Any ideas?


    last time I checked, connect(":memory:") creates a new blank database
    every time it is called.

    </F>
    Fredrik Lundh, Mar 1, 2006
    #6
  7. Guest

    I tried using the path "c:\ex1.db" and it worked. I was using "ex1.db"
    before.

    Thanks everyone for the help. This is a great community and maybe next
    time I will ask a harder question :)
    , Mar 1, 2006
    #7
    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. Hemanth P.S.
    Replies:
    0
    Views:
    348
    Hemanth P.S.
    Sep 18, 2003
  2. John Abel

    Problem Building PySQLite (Win32)

    John Abel, Oct 30, 2003, in forum: Python
    Replies:
    1
    Views:
    354
  3. F. GEIGER
    Replies:
    2
    Views:
    541
    F. GEIGER
    May 21, 2005
  4. rdrink

    pysqlite - simple problem

    rdrink, Sep 1, 2006, in forum: Python
    Replies:
    12
    Views:
    1,177
    Dennis Lee Bieber
    Sep 3, 2006
  5. Gerhard Häring
    Replies:
    3
    Views:
    376
    Gerhard Häring
    Mar 13, 2008
Loading...

Share This Page