Re: Simple sqlite3 question

2007-04-26 Thread Tim Roberts
cjl [EMAIL PROTECTED] wrote: I am using python 2.5.1 on windows. I have the following code: conn = sqlite3.connect('.\optiondata') This is unrelated to your question, but you have a slash problem there. \o doesn't happen to be a valid escape character, but if you had used testdata as the

Simple sqlite3 question

2007-04-24 Thread cjl
P: I am using python 2.5.1 on windows. I have the following code: conn = sqlite3.connect('.\optiondata') c = conn.cursor() try: c.execute('''create table options (ssymbol text, strike real, osymbol text, bid real, mpp real, upp real)''') except sqlite3.OperationalError: pass I am hoping

Re: Simple sqlite3 question

2007-04-24 Thread Jerry Hill
On 24 Apr 2007 10:03:45 -0700, cjl [EMAIL PROTECTED] wrote: When I run the script and there is no file named optiondata, one is created and the correct data is added to it. If I run the script again then the data from the first run seems to be replaced with the data from the second run. I

Re: Simple sqlite3 question

2007-04-24 Thread John Nagle
Jerry Hill wrote: On 24 Apr 2007 10:03:45 -0700, cjl [EMAIL PROTECTED] wrote: When I run the script and there is no file named optiondata, one is created and the correct data is added to it. If I run the script again then the data from the first run seems to be replaced with the data from

Re: sqlite3 question

2007-04-16 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Gabriel Genellina wrote: En Thu, 12 Apr 2007 08:43:49 -0300, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] escribió: In [EMAIL PROTECTED], Jorgen Bodde wrote: r = c.execute('select * from song where id = 1') for s in r: ... print s ... (1,

Re: sqlite3 question

2007-04-15 Thread Gabriel Genellina
En Thu, 12 Apr 2007 08:43:49 -0300, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] escribió: In [EMAIL PROTECTED], Jorgen Bodde wrote: r = c.execute('select * from song where id = 1') for s in r: ... print s ... (1, u'Spikedrivers Blues', u'Mississippi John Hurt') This should not work

Re: sqlite3 question

2007-04-13 Thread Jorgen Bodde
Thanks, This is how I did it in the end as well. Yes i use the connection object, abbreviated as 'c' for ease of typing. In my real app the connection is kept inside a singleton object and I use the DB like result = GuitarDB().connection.execute('select * from song where id = 1').fetchone() if

sqlite3 question

2007-04-12 Thread Jorgen Bodde
Hi all, I am using sqlite3 in python, and I wonder if there is a way to know if there are valid rows returned or not. For example I have a table song with one entry in it. The ID of that entry is 1, so when I do; r = c.execute('select * from song where id = 1') for s in r: ... print s ...

Re: sqlite3 question

2007-04-12 Thread Rob Wolfe
Jorgen Bodde wrote: All I can think of is a 'crappy' construction where I use the iterator to see if there was something in there, but surely, there must be a better way to know? r = c.execute('select * from song where id = 2') notfound = True for s in r: ... notfound = False ...

Re: sqlite3 question

2007-04-12 Thread Gabriel Genellina
En Thu, 12 Apr 2007 04:38:06 -0300, Jorgen Bodde [EMAIL PROTECTED] escribió: I am using sqlite3 in python, and I wonder if there is a way to know if there are valid rows returned or not. For example I have a table song with one entry in it. The ID of that entry is 1, so when I do; r =

Re: sqlite3 question

2007-04-12 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Jorgen Bodde wrote: r = c.execute('select * from song where id = 1') for s in r: ... print s ... (1, u'Spikedrivers Blues', u'Mississippi John Hurt') That works. But when I can't restore the row by e.g. an ID that does not exist, I cannot see any method in 'r'

Re: sqlite3 question

2007-04-12 Thread Carsten Haese
On Thu, 2007-04-12 at 13:43 +0200, Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Jorgen Bodde wrote: r = c.execute('select * from song where id = 1') for s in r: ... print s ... (1, u'Spikedrivers Blues', u'Mississippi John Hurt') That works. But when I