Posted to tcl by aspect at Sun Sep 14 10:43:31 GMT 2014view raw
- # FIXME:
- # - table names are not armoured (because different backends require different armouring!)
- # - column names need to be in [a-zA-Z0-9_] for tdbc's binding syntax to work
- proc copy_table {fromdb fromtable todb totable} {
- set sst [$fromdb prepare "select * from $fromtable"]
- set srs [$sst execute]
- set cols [$srs columns]
- set dst [$todb prepare "insert into $totable ([join $cols ,]) values (:[join $cols ,:])"]
- $dst transaction {
- $srs foreach rec $sql {
- $dst execute $rec
- }
- }
- $sst destroy
- $dst destroy
- }