getting file size for all dict files to be downloaded. coming to be 400mb or so.
[worddb.git] / libs / dmigrations / .svn / text-base / migration_log.py.svn-base
blobfe436a6950c9436841fa53d4f0318c5a83059321
1 import datetime
2 from migration_state import _execute, _execute_in_transaction, table_present
4 MIGRATION_LOG_SQL = """
5     CREATE TABLE `dmigrations_log` (
6     `id` int(11) NOT NULL auto_increment,
7     `action` VARCHAR(255) NOT NULL,
8     `migration` VARCHAR(255) NOT NULL,
9     `status` VARCHAR(255) NOT NULL,
10     `datetime` DATETIME NOT NULL,
11      PRIMARY KEY  (`id`)
12     ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
13 """
15 def init():
16     """
17     Create migration log if it doesn't exist
18     """
19     if not table_present('dmigrations_log'):
20       _execute(MIGRATION_LOG_SQL)
21   
22 def get_log():
23     return list(_execute("""
24         SELECT action, migration, status, datetime 
25         FROM dmigrations_log 
26         ORDER BY datetime, id"""
27     ).fetchall())
29 def log_action(action, migration, status, when=None):
30     if when == None:
31         when = datetime.datetime.now()
32     _execute_in_transaction("""
33         INSERT INTO dmigrations_log(action, migration, status, datetime) 
34         VALUES (%s, %s, %s, %s)
35     """, [action, migration, status, when])