SPUG:DB two-way synchronization

Terry Nightingale tnight at pobox.com
Thu May 15 18:22:38 CDT 2003


Michael R. Wolf wrote:

[snip]
> It's the same problem as a PDA sync'ing to a PC for calendar, note,
> email, or contact information. I know it's not an easy theoretical
> algorithm, but at least it's one that's been solved. I'd like to build
> my solution on top of that work rather than reinvent it.

I'm not personally aware of any such algorithm, but that doesn't mean it 
does not exist.  The way I've seen this sort of problem handled is 
through the use of update timestamps and a few reasonable assumptions.

The best-case scenario is having an update timestamp for every field of 
data.  Then, the merge is a simple matter of going through the data, 
field by field, and comparing the update dates.  The most recent wins.

Usually, you don't have a field-based update timestamp, but a 
record-based timestamp.  In that case, you have to let the most recently 
updated record win, except when the data in a field in the most recently 
updated record is blank or meaningless (fails a /\w+/ match, for 
example), and the same field in the less recently updated record 
contains more meaningful data.

> A and B are not just arbitrary names:
>   A is for ACT!, a contact manager that should be ODBC-accessible
>   B is for BBDB, emacs' Big Brother Data Base
> 
> I know the DBD::ODBC module exists. (I'll have to come up to speed on
> it. [1])

It's not bad.  To get started, I'd recommend using ActivePerl and a 
Microsoft Access Database.  Set up a data source for your Access 
database, and write a few simple Perl scripts to manipulate the data 
using DBI with DBD::ODBC.  Then, move on to trying to access and 
manipulate the Act! data.

> I'll have to build a DBD::application::emacs::BBDB interface, either
> directly to its lisp-like textual file representation, or through the
> behaviors coded in emacs' elisp as an API. Anyone done something
> similar? Ideas? It's no small feat, I'd imagine. [2]

If the data is really stored in a text format, you're probably better 
off writing a DBD::whatever module to interface with the text file 
directly.  There should be at least a few pure-Perl DBD drivers out on 
CPAN that you could use as a starting point.  The DBD::Sprite module is 
one that I can think of off hand.

Best of luck!


-- 
Terry Nightingale <tnight at pobox.com>
Web Developer, Philosopher, Geek
"In theory, there is no difference between theory and practice. But, in
practice, there is." -- Jan L.A. van de Snepscheut
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3411 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030515/2552d1e1/smime.bin


More information about the spug-list mailing list