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


Groups > comp.lang.python > #26042

Re: Dumping all the sql statements as backup

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tdldev@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.078
X-Spam-Evidence '*H*': 0.84; '*S*': 0.00; 'badly': 0.07; 'received:209.85.160.174': 0.07; 'dump': 0.16; 're-run': 0.16; 'sqlalchemy': 0.16; 'wrote:': 0.17; 'duplicate': 0.17; 'code,': 0.18; 'file.': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'received:10.0.0': 0.28; 'run': 0.28; 'statements': 0.29; 'subject:all': 0.29; 'probably': 0.29; 'code': 0.31; 'file': 0.32; 'running': 0.32; 'goes': 0.33; 'like:': 0.33; 'received:10.0': 0.33; 'problem': 0.33; 'anyone': 0.33; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'needed': 0.35; 'data,': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'useful': 0.36; 'problems': 0.36; 'execute': 0.37; 'why': 0.37; 'moment': 0.37; 'previous': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'things': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'build': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'day': 0.73; 'andrea': 0.84; 'received:10.0.0.2': 0.84; 'simulations': 0.84; 'solvable': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=F3MBG6s3ButOLBbAXYf1YlZKSro3VWaShHJ29xfaXl4=; b=ur+fc4iG1xn5pGEclc0FfsTTJW61hZliZ+4v0eSVO9OUejOiHOkAdTz3xZpGXhQ19A FMZnTl/YA1S98kaGZc1BbUVyBp3XsgBbzVOC7j0B6HMkJ0ATaW+vxjSw//sliBchynVu nbH1ye0hKIma3qbfeV120nM5Z/SCCCkYfqCvLRW+7Bqs15YDeH9+SzgLKumOAgsbE2V6 XDqoIn1RgKalFNbRkffaBePGTP5qiwnx1MtbqG4C9ZcygUlWHF34SkShYWvN9fVGaQM0 9W/kEEAJY61DhQoBhe/fi9G8sBgxO7miHmAYjv8ITMItdCX9OF2SMPWuAvyjgSsg+l7Q IRDg==
Date Wed, 25 Jul 2012 10:52:45 -0400
From Jack <tdldev@gmail.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20120613 Iceowl/1.0b1 Icedove/3.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: Dumping all the sql statements as backup
References <CAF_E5JYTMZ9CbAeSabdoK9HfHQ5tgdSnGFua5nQL6kQ85nw2tw@mail.gmail.com>
In-Reply-To <CAF_E5JYTMZ9CbAeSabdoK9HfHQ5tgdSnGFua5nQL6kQ85nw2tw@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.2573.1343227585.4697.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1343227585 news.xs4all.nl 6916 [2001:888:2000:d::a6]:43040
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26042

Show key headers only | View raw


On 07/25/2012 09:56 AM, andrea crotti wrote:
> I have some long running processes that do very long simulations which
> at the end need to write things on a database.
>
> At the moment sometimes there are network problems and we end up with
> half the data on the database.
>
> The half-data problem is probably solved easily with sessions and
> sqlalchemy (a db-transaction), but still we would like to be able to
> keep a backup SQL file in case something goes badly wrong and we want to
> re-run it manually..
>
> This might also be useful if we have to rollback the db for some reasons
> to a previous day and we don't want to re-run the simulations..
>
> Anyone did something similar?
> It would be nice to do something like:
>
> with CachedDatabase('backup.sql'):
>     # do all your things
>   
Since you know the content of what the sql code is, why not just build
the sql file(s) needed and store them so that in case of a burp you can
just execute the code file. If you don't know the exact sql code, dump
it to a file as the statements are constructed... The only problem you
would run into in this scenario is duplicate data, which is also easily
solvable by using transaction-level commits to the db.

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


Thread

Re: Dumping all the sql statements as backup Jack <tdldev@gmail.com> - 2012-07-25 10:52 -0400

csiph-web