Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.05; 'subject:Python': 0.06; 'table.': 0.07; 'referenced': 0.09; 'subject:2.7': 0.09; 'cc:addr:python-list': 0.11; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'multi-column': 0.16; 'strange,': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'exists': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'references': 0.26; 'primary': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'text': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'nov': 0.38; 'pm,': 0.38; 'according': 0.40; 'name': 0.63; 'field': 0.63; 'foreign': 0.74; 'trick.': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=AcmuWp37AO+pwJgNjaKmJUofPdHmszkUg1VyRBiUbG8=; b=dmuzDze936mPUMU3UjQuJ05odG5ozvvEZVGws/Wa/o1djuuPDBhyiCbZPasxswX7t0 UsTy64gC0/SJbADTMKPSDeV55yrA3nzCwlVronQWgzNU5Awzqd9WL7gbV2kp/ThpDnUD /JapU25c2jrthJs6nI/hZnTOHXaiXYRw4u5MR9A9997YwiKcGYtMbUYo9LKbrj/qrJol BVNgspdew5tug2ouRun7mdwFH+njgsDYGnuIBNPXn90SlL4x2PIh1xdE4gGeZdN9jDQ1 5OA+9s8x8ZMjbEe11AB4W6UDpCcV9YVIp3kXy1rSjQAdKO0CzWqATAs+1icY/l/oEer3 wIUQ== MIME-Version: 1.0 X-Received: by 10.42.110.195 with SMTP id r3mr22867815icp.12.1416804565369; Sun, 23 Nov 2014 20:49:25 -0800 (PST) In-Reply-To: <3e96ab9c-248f-41da-a07c-8f1c53b07931@googlegroups.com> References: <3e96ab9c-248f-41da-a07c-8f1c53b07931@googlegroups.com> Date: Mon, 24 Nov 2014 15:49:25 +1100 Subject: Re: SQLite3 in Python 2.7 Rejecting Foreign Key Insert From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416804574 news.xs4all.nl 2915 [2001:888:2000:d::a6]:52204 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81425 On Mon, Nov 24, 2014 at 1:22 PM, llanitedave wrote: > I recreated the table and put the foreign key reference directly into the field definition: > > "of_borehole TEXT NOT NULL REFERENCES borehole," > > This is a valid alternative according to the SQLite3 docs, if you don't explicitly define the field name then it references to the primary key that already exists in the referenced table. > > And that's all I had to do. Strange, but it did the trick. That's also perfectly valid according to the SQL spec. I prefer to put the foreign key up there where possible (obviously it's not possible with a multi-column FK, but those aren't common). Strange that the other form doesn't work. ChrisA