From 1ec5221d823cdc570bd94b0aca24681be92f72e4 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 26 Mar 2010 20:51:55 +0000 Subject: [PATCH] minor update --- lib/core/replication.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/core/replication.py b/lib/core/replication.py index 2ced2b33d..b128e31ac 100644 --- a/lib/core/replication.py +++ b/lib/core/replication.py @@ -43,14 +43,16 @@ class Replication: return "" % self class Table: - def __init__(self, parent, name, columns, typeless=False): + def __init__(self, parent, name, columns=None, create=True, typeless=False): self.parent = parent self.name = name self.columns = columns - if not typeless: - self.parent.cursor.execute('CREATE TABLE %s (%s)' % (name, ','.join('%s %s' % (colname, coltype) for colname, coltype in columns))) - else: - self.parent.cursor.execute('CREATE TABLE %s (%s)' % (name, ','.join(colname for colname in columns))) + if create: + self.parent.cursor.execute('DROP TABLE IF EXISTS %s' % self.name) + if not typeless: + self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join('%s %s' % (colname, coltype) for colname, coltype in self.columns))) + else: + self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join(colname for colname in self.columns))) def insert(self, rows): self.parent.cursor.executemany('INSERT INTO %s VALUES (?,?,?,?,?)' % self.name, rows)