Mercurial > p > roundup > code
comparison roundup/backends/back_mysql.py @ 2417:fe722c32ce0c maint-0.7
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 09 Jun 2004 06:16:56 +0000 |
| parents | 1ccfcfeca61b |
| children | e4f06fcbbc89 |
comparison
equal
deleted
inserted
replaced
| 2408:e12a610eb7f3 | 2417:fe722c32ce0c |
|---|---|
| 335 | 335 |
| 336 # make sure the normal schema update code doesn't try to | 336 # make sure the normal schema update code doesn't try to |
| 337 # change things | 337 # change things |
| 338 self.database_schema['tables'][cn] = klass.schema() | 338 self.database_schema['tables'][cn] = klass.schema() |
| 339 | 339 |
| 340 def fix_version_2_tables(self): | |
| 341 # Convert journal date column to TIMESTAMP, params column to TEXT | |
| 342 self._convert_journal_tables() | |
| 343 | |
| 344 # Convert all String properties to TEXT | |
| 345 self._convert_string_properties() | |
| 346 | |
| 340 def __repr__(self): | 347 def __repr__(self): |
| 341 return '<myroundsql 0x%x>'%id(self) | 348 return '<myroundsql 0x%x>'%id(self) |
| 342 | 349 |
| 343 def sql_fetchone(self): | 350 def sql_fetchone(self): |
| 344 return self.cursor.fetchone() | 351 return self.cursor.fetchone() |
| 351 for index in self.cursor.fetchall(): | 358 for index in self.cursor.fetchall(): |
| 352 if index[2] == index_name: | 359 if index[2] == index_name: |
| 353 return 1 | 360 return 1 |
| 354 return 0 | 361 return 0 |
| 355 | 362 |
| 356 def save_dbschema(self, schema): | 363 def create_class_table(self, spec, create_sequence=True): |
| 357 s = repr(self.database_schema) | |
| 358 self.sql('INSERT INTO schema VALUES (%s)', (s,)) | |
| 359 | |
| 360 def create_class_table(self, spec): | |
| 361 cols, mls = self.determine_columns(spec.properties.items()) | 364 cols, mls = self.determine_columns(spec.properties.items()) |
| 362 | 365 |
| 363 # add on our special columns | 366 # add on our special columns |
| 364 cols.append(('id', 'INTEGER PRIMARY KEY')) | 367 cols.append(('id', 'INTEGER PRIMARY KEY')) |
| 365 cols.append(('__retired__', 'INTEGER DEFAULT 0')) | 368 cols.append(('__retired__', 'INTEGER DEFAULT 0')) |
| 389 if __debug__: | 392 if __debug__: |
| 390 print >>hyperdb.DEBUG, 'drop_index', (self, index_sql) | 393 print >>hyperdb.DEBUG, 'drop_index', (self, index_sql) |
| 391 self.cursor.execute(index_sql) | 394 self.cursor.execute(index_sql) |
| 392 | 395 |
| 393 def create_journal_table(self, spec): | 396 def create_journal_table(self, spec): |
| 397 ''' create the journal table for a class given the spec and | |
| 398 already-determined cols | |
| 399 ''' | |
| 394 # journal table | 400 # journal table |
| 395 cols = ','.join(['%s varchar'%x | 401 cols = ','.join(['%s varchar'%x |
| 396 for x in 'nodeid date tag action params'.split()]) | 402 for x in 'nodeid date tag action params'.split()]) |
| 397 sql = '''create table %s__journal ( | 403 sql = '''create table %s__journal ( |
| 398 nodeid integer, date timestamp, tag varchar(255), | 404 nodeid integer, date datetime, tag varchar(255), |
| 399 action varchar(255), params text) type=%s'''%( | 405 action varchar(255), params text) type=%s'''%( |
| 400 spec.classname, self.mysql_backend) | 406 spec.classname, self.mysql_backend) |
| 401 if __debug__: | 407 if __debug__: |
| 402 print >>hyperdb.DEBUG, 'create_journal_table', (self, sql) | 408 print >>hyperdb.DEBUG, 'create_journal_table', (self, sql) |
| 403 self.cursor.execute(sql) | 409 self.cursor.execute(sql) |
