comparison roundup/backends/back_sqlite.py @ 3156:e1da7b5b04ab maint-0.8

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Mon, 14 Feb 2005 02:55:31 +0000
parents a7045bad20de
children 43675a5232b1
comparison
equal deleted inserted replaced
3154:62b1a54107e6 3156:e1da7b5b04ab
1 # $Id: back_sqlite.py,v 1.36.2.2 2005-01-04 01:33:03 richard Exp $ 1 # $Id: back_sqlite.py,v 1.36.2.3 2005-02-14 02:55:31 richard Exp $
2 '''Implements a backend for SQLite. 2 '''Implements a backend for SQLite.
3 3
4 See https://pysqlite.sourceforge.net/ for pysqlite info 4 See https://pysqlite.sourceforge.net/ for pysqlite info
5 5
6 6
7 NOTE: we use the rdbms_common table creation methods which define datatypes 7 NOTE: we use the rdbms_common table creation methods which define datatypes
8 for the columns, but sqlite IGNORES these specifications. 8 for the columns, but sqlite IGNORES these specifications.
9 ''' 9 '''
10 __docformat__ = 'restructuredtext' 10 __docformat__ = 'restructuredtext'
11 11
12 import os, base64, marshal, shutil, time 12 import os, base64, marshal, shutil, time, logging
13 13
14 from roundup import hyperdb, date, password 14 from roundup import hyperdb, date, password
15 from roundup.backends import locking 15 from roundup.backends import locking
16 from roundup.backends import rdbms_common 16 from roundup.backends import rdbms_common
17 import sqlite 17 import sqlite
83 # database itself will be created by sqlite if needed 83 # database itself will be created by sqlite if needed
84 if not os.path.isdir(self.config.DATABASE): 84 if not os.path.isdir(self.config.DATABASE):
85 os.makedirs(self.config.DATABASE) 85 os.makedirs(self.config.DATABASE)
86 86
87 db = os.path.join(self.config.DATABASE, 'db') 87 db = os.path.join(self.config.DATABASE, 'db')
88 self.config.logging.getLogger('hyperdb').info('open database %r'%db) 88 logging.getLogger('hyperdb').info('open database %r'%db)
89 conn = sqlite.connect(db=db) 89 conn = sqlite.connect(db=db)
90 # set a 30 second timeout (extraordinarily generous) for handling 90 # set a 30 second timeout (extraordinarily generous) for handling
91 # locked database 91 # locked database
92 conn.db.sqlite_busy_handler(self.sqlite_busy_handler) 92 conn.db.sqlite_busy_handler(self.sqlite_busy_handler)
93 cursor = conn.cursor() 93 cursor = conn.cursor()
157 old_spec[1].sort() 157 old_spec[1].sort()
158 if not force and new_spec == old_spec: 158 if not force and new_spec == old_spec:
159 # no changes 159 # no changes
160 return 0 160 return 0
161 161
162 self.config.logging.getLogger('hyperdb').info('update_class %s'%spec.classname) 162 logging.getLogger('hyperdb').info('update_class %s'%spec.classname)
163 163
164 # detect multilinks that have been removed, and drop their table 164 # detect multilinks that have been removed, and drop their table
165 old_has = {} 165 old_has = {}
166 for name, prop in old_spec[1]: 166 for name, prop in old_spec[1]:
167 old_has[name] = 1 167 old_has[name] = 1

Roundup Issue Tracker: http://roundup-tracker.org/