sqlite3 puzzle

llanitedave llanitedave at veawb.coop
Tue Jan 15 17:46:12 EST 2013


Yabut I'm talking about changes I'd made 30 seconds before to code I'd written 5 minutes before.  My short-term memory is nothing to write home about, even if I could remember my mailing address!


On Tuesday, January 15, 2013 2:27:28 PM UTC-8, Rob Day wrote:
> Glad I could help!
> 
> 
> 
> <evangelism>
> 
> Using a local source control system like git, bzr or hg is really
> 
> useful in situations like these - it's far, far easier to debug issues
> 
> of the form "I made changes and now it's broken" when you can do `git
> 
> diff yesterday's-version today's-version` and see exactly what the
> 
> changes were.
> 
> </evangelism>
> 
> 
> 
> On 15 January 2013 20:29, llanitedave <llanitedave at veawb.coop> wrote:
> 
> > On Tuesday, January 15, 2013 9:13:13 AM UTC-8, Rob Day wrote:
> 
> >> On 15 January 2013 15:51, llanitedave <llanitedave at veawb.coop> wrote:
> 
> >>
> 
> >> > Thanks for the suggestion, Rob, but that didn't make any difference.  I've never had an issue with putting the execute object into a variable and calling "fetch" on that variable.
> 
> >>
> 
> >> >
> 
> >>
> 
> >> > I can accept reality if it turns out that foreign keys simply isn't enabled on the Python distribution of sqlite, although I don't know why that should be the case.  I'm just curious as to why it worked at first and then stopped working.
> 
> >>
> 
> >>
> 
> >>
> 
> >> Well - you might be able to accept that, but I'm not sure I can! If it
> 
> >>
> 
> >> was working before, it must be compiled in, and so it must be possible
> 
> >>
> 
> >> to make it work again.
> 
> >>
> 
> >>
> 
> >>
> 
> >> http://www.sqlite.org/foreignkeys.html#fk_enable seems to suggest that
> 
> >>
> 
> >> "PRAGMA foreign_keys = ON" never returns anything, and it's only
> 
> >>
> 
> >> "PRAGMA foreign_keys" which returns 0, 1 or None (when unsupported).
> 
> >>
> 
> >> With that in mind, does the following code work?
> 
> >>
> 
> >>
> 
> >>
> 
> >> # open database file
> 
> >>
> 
> >>
> 
> >>
> 
> >> self.geologger_db = sqlite3.connect('geologger.mgc')
> 
> >>
> 
> >> self.db_cursor = self.geologger_db.cursor()
> 
> >>
> 
> >> self.db_cursor.execute("PRAGMA foreign_keys = ON")
> 
> >>
> 
> >> self.db_cursor.execute("PRAGMA foreign_keys")
> 
> >>
> 
> >> print self.db_cursor.fetchone()
> 
> >
> 
> > "http://www.sqlite.org/foreignkeys.html#fk_enable seems to suggest that "PRAGMA foreign_keys = ON" never returns anything, and it's only "PRAGMA foreign_keys" which returns 0, 1 or None (when unsupported)."
> 
> >
> 
> > That was it, exactly, Rob.  I don't know where I got the idea that I was getting  a '1' from the 'ON' command, although I was sure that I'd seen it.  But once I just called "foreign_key" it returned just fine.
> 
> >
> 
> > Ummm...  Obviously I was up fiddling around too late.  Yeah, that's it.
> 
> >
> 
> >
> 
> > Thanks!  It's solved now.
> 
> > --
> 
> > http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Robert K. Day
> 
> robert.day at merton.oxon.org




More information about the Python-list mailing list