Check-in [a23e710131]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Create and populate watermark table in a transaction.
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1:a23e710131a40466fe1c8e05f718c5fe63037cca
User & Date: mvnathan 2014-09-19 00:36:34
Context
2014-09-19
04:20
Updated documentation about watermarking. check-in: ea1817df1f user: mvnathan tags: dev
00:36
Create and populate watermark table in a transaction. check-in: a23e710131 user: mvnathan tags: dev
00:33
Added a helper class to ease database Morgification and verification. check-in: 5013209038 user: mvnathan tags: dev
Changes

Changes to py/morglib/database.py.

299
300
301
302
303
304
305

306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321
322
        '''Create Morg's identification table.

        This internal method creates and populates the <tt>morg</tt>
        table, which is used to identify SQLite files as "belonging" to
        Morg.

        '''

        logger.info('creating morg table')
        wm = watermark()
        wm.dump()
        self.execute(wm.create())

        logger.info('populating morg table')
        columns = wm.columns()
        insert  = ('insert into morg ({}) values ({})'.

                   format(','.join(columns), ','.join('?' * len(columns))))
        self.execute(insert, tuple(wm))

    def _sanity_check(self, tasks_file):
        '''Try and confirm we're dealing with a Morg database.

        @param tasks_file (string) Name of SQLite file.

        Morg creates a table named <tt>morg</tt> in which it stores the







>
|
|
|
|

|
|
|
>
|
|







299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
        '''Create Morg's identification table.

        This internal method creates and populates the <tt>morg</tt>
        table, which is used to identify SQLite files as "belonging" to
        Morg.

        '''
        with self._db:
            logger.info('creating morg table')
            wm = watermark()
            wm.dump()
            self.execute(wm.create())

            logger.info('populating morg table')
            columns = wm.columns()
            insert  = ('insert into morg ({}) values ({})'.
                       format(','.join(columns),
                              ','.join('?' * len(columns))))
            self.execute(insert, tuple(wm))

    def _sanity_check(self, tasks_file):
        '''Try and confirm we're dealing with a Morg database.

        @param tasks_file (string) Name of SQLite file.

        Morg creates a table named <tt>morg</tt> in which it stores the

Changes to wiki/todo.wiki.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
  *  Create <tt>property</tt> table on database init.
  *  Add default properties dict.
  *  Create <tt>property_NNN</tt> tables on database init.
  *  Implement sanity check on database initialization.
  *  Update database constructor doc string.
  *  Use the BETWEEN operator in property range constraints.
  *  Implement a watermark class to ease verification and "Morgification."


<h2>PENDING</h2>

  *  The watermark table should be created and populated in a transaction.
  *  Update doc strings to reflect recent changes about the watermark.
  *  Pass database to all commands' <tt>__call__</tt> method.
  *  Implement <tt>new</tt> command.







>



<



17
18
19
20
21
22
23
24
25
26
27

28
29
30
  *  Create <tt>property</tt> table on database init.
  *  Add default properties dict.
  *  Create <tt>property_NNN</tt> tables on database init.
  *  Implement sanity check on database initialization.
  *  Update database constructor doc string.
  *  Use the BETWEEN operator in property range constraints.
  *  Implement a watermark class to ease verification and "Morgification."
  *  The watermark table should be created and populated in a transaction.

<h2>PENDING</h2>


  *  Update doc strings to reflect recent changes about the watermark.
  *  Pass database to all commands' <tt>__call__</tt> method.
  *  Implement <tt>new</tt> command.