Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:skip:c 10': 0.07; 'wrapper': 0.07; 'normally,': 0.09; 'storage.': 0.09; '(like': 0.15; 'commit': 0.15; '(assuming': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iirc': 0.16; 'postgresql)': 0.16; 'record,': 0.16; 'sqlalchemy': 0.16; 'subject:issue': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'written,': 0.17; 'jan': 0.18; 'windows': 0.19; 'changes': 0.20; 'written': 0.20; 'libraries': 0.22; 'work,': 0.22; 'raise': 0.24; 'command': 0.24; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'received:209.85.212': 0.28; 'durable': 0.29; 'once.': 0.29; 'storage,': 0.29; "i'm": 0.29; 'usually': 0.30; 'returned': 0.30; 'getting': 0.33; 'that!': 0.33; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'depends': 0.36; "wasn't": 0.36; 'method': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'unit': 0.38; 'several': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'first': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.63; 'afraid': 0.66; 'saving': 0.72; 'guaranteed': 0.76; '2013': 0.84; 'wow': 0.84; 'mistake': 0.91; 'transactions': 0.91 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:to :content-type; bh=242/2tF6v6nsrufnBNDySvzpzW/xJpLcp6OsoiAwv1U=; b=ZtMJxwy5YfmdhtO358/ogIH6lH28DussaTPvPwVBD74Zyorfx1B1i2a212aonuqpWg whvnuViqI76A386b/6LxzMc+D/ectgdSVkyVaU7V2ouveEXpiSdISsrVU4tM4WZwk4jR +Fw8+DznHLFVX3YKSiyTydueVVLA8ixo9lPeQVJmsNk9+E7+RHUOtUyDaVXPYmy9B2Co i/O/qsJ661VnG7R69CA7lPDouKmCJJSJdEYGSUHT1QwOULLoDTzYG3LrfbNaCV4QCOia ftuKAh32sdM6wQKcC21wOCZMwz4uUG9AkAYKAtCuCPQOcOM0Jz4fRlpoY8IykUcD7cSU mX5A== MIME-Version: 1.0 In-Reply-To: <50E9F74A.70107@lightbird.net> References: <185b6d9e-99ce-4f2a-81ea-d9a63b81b4cf@googlegroups.com> <10bc4895-21e3-4a56-84fd-b0830e42acfa@googlegroups.com> <50E9F74A.70107@lightbird.net> Date: Mon, 7 Jan 2013 09:19:50 +1100 Subject: Re: psycopg2 cursor.execute CREATE TABLE issue From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357510798 news.xs4all.nl 6852 [2001:888:2000:d::a6]:56404 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36294 On Mon, Jan 7, 2013 at 9:14 AM, Mitya Sirenef wrote: > On Sun 06 Jan 2013 04:53:32 PM EST, andydtaylor@gmail.com wrote: >> >> Wow it's as simple as that! I'm afraid my database experience is in >> Microsoft Access in Windows and not at the command line, so that wasn't >> intuitive for me. >> > IIRC I made the same mistake when I was using psycopg for the first time. > I think wrapper libraries like sqlalchemy usually have myrecord.save() > method which is more intuitive. I recommend getting used to thinking in terms of transactions and commits. Instead of saving a record, commit a unit of work, which might involve several changes all at once. A good database (like PostgreSQL) will guarantee you that either the whole transaction has happened, or none of it has. And normally, once your commit call has returned (assuming it doesn't raise an error), you're guaranteed that the transaction has been completely written to durable storage. Of course, that depends on *having* durable storage, and many SSDs lie about what's been written, but that's outside the scope of this post! ChrisA