Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36856

Re: sqlite3 puzzle

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <robertkday@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'enabled.': 0.07; 'subject:sqlite3': 0.07; 'effect.': 0.09; 'method:': 0.09; 'cc:addr:python-list': 0.10; 'suggest': 0.11; 'downstream': 0.16; 'placeholder': 0.16; 'wrote:': 0.17; 'sender:addr:gmail.com': 0.18; 'variable': 0.20; 'keys': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'change,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'returned': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; "skip:' 20": 0.32; 'print': 0.32; 'skip:s 30': 0.33; 'docs': 0.33; 'changed': 0.34; 'received:google.com': 0.34; 'robert': 0.35; 'open': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'test': 0.36; 'should': 0.36; 'does': 0.37; 'previous': 0.37; 'quite': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'several': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'times': 0.63; 'more': 0.63; 'foreign': 0.72; 'day': 0.73; '2013': 0.84; 'descriptive': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=YKDHNKg1QtSK6j7nETIa/x8sYGI1GEBuKd30XpbrRso=; b=PfEQM7B0Dz2aGtiWt4t67AL+VRWcC4tJdNHt5ya7FqJyS99Z+scNwdThmzLTWSQZkN ttV0cfxV2sQc18mAHdaTBhfleFzyFsNmBs6TP5Ls03L2GqklLZd4mIJ/SAULizNvAyJI XMQe6+LS/FOdkjM3+l/ttTZcxWd5DeaRdI25bOHxi6UKDB5ODLECcOUwCA25KzoaSrmP xi9mArFbeOOr3c49OYPSzzkqwWaF5dbzOch0oi/35RFjSJlyQe5fbKXnylzg1JUgGWCx tvSgJzocrBRlyKQrvtyJ3MiwIR6ptECeY2sJPpljDnsoZRmlEJze9kxgP9Q4as2nQCc0 BNzw==
MIME-Version 1.0
Sender robertkday@gmail.com
In-Reply-To <a8e71415-57fc-4284-82fe-fae0a6670a67@googlegroups.com>
References <a8e71415-57fc-4284-82fe-fae0a6670a67@googlegroups.com>
Date Tue, 15 Jan 2013 14:36:51 +0000
X-Google-Sender-Auth XS--mbRKq3nq0WitrRuEL9yu3PM
Subject Re: sqlite3 puzzle
From Rob Day <robert.day@merton.oxon.org>
To llanitedave <llanitedave@veawb.coop>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.540.1358260620.2939.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358260621 news.xs4all.nl 6901 [2001:888:2000:d::a6]:32775
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36856

Show key headers only | View raw


On 15 January 2013 07:09, llanitedave <llanitedave@veawb.coop> wrote:

> So I put the following test code in my initialization method:
>
>     # open database file
>     self.geologger_db = sqlite3.connect('geologger.mgc')
>     self.db_cursor = self.geologger_db.cursor()
>     self.foreign_key_status = self.db_cursor.execute("PRAGMA foreign_keys = ON")
>     self.foreign_key_status = self.foreign_key_status.fetchone()
>
>     print self.foreign_key_status
>
> I ran this several times while I was arranging the downstream queries, and each time it returned '(1,)', which means foreign keys is enabled.
>
> But I was using a variable named 'cmd1' as a placeholder until I changed the name to
> the more descriptive 'self.foreign_key_status'.  Since I made the name change, however,
> the code only returns 'None'.  Reverting to the previous variable name has no effect.

Hmm - your code doesn't quite match up with the docs at
http://docs.python.org/2/library/sqlite3.html. That seems to suggest
that you should call fetchone() on the cursor, not on the result of
execute().

Does the following 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")
    print self.db_cursor.fetchone()


--
Robert K. Day
robert.day@merton.oxon.org

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-14 23:09 -0800
  Re: sqlite3 puzzle Rob Day <robert.day@merton.oxon.org> - 2013-01-15 14:36 +0000
    Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 07:51 -0800
      Re: sqlite3 puzzle Rob Day <robert.day@merton.oxon.org> - 2013-01-15 17:13 +0000
        Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 12:29 -0800
          Re: sqlite3 puzzle Rob Day <robert.day@merton.oxon.org> - 2013-01-15 22:27 +0000
            Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 14:46 -0800
            Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 14:46 -0800
        Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 12:29 -0800
    Re: sqlite3 puzzle llanitedave <llanitedave@veawb.coop> - 2013-01-15 07:51 -0800
  Re: sqlite3 puzzle inq1ltd <inq1ltd@inqvista.com> - 2013-01-15 11:54 -0500

csiph-web