By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,605 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

pysqlite problem

P: n/a
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 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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 '06 #2

P: n/a
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.

Mar 1 '06 #3

P: n/a
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').

Mar 1 '06 #4

P: n/a
ba*****@gmail.com 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>

Mar 1 '06 #5

P: n/a
>>>>> bapolis <ba*****@gmail.com> 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
Mar 1 '06 #6

P: n/a
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 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.