File: dumpdata.tcl

package info (click to toggle)
tclodbc 2.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,428 kB
  • sloc: sh: 2,765; cpp: 2,039; tcl: 591; makefile: 220
file content (30 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
####################################################################
#
# dumpdata.tcl
#
# Dump data from every table of the database to a file. 
# 
# Uses utility procedure DumpTable in file datautil.tcl
#

# Create the db, if not yet created.
set dir [file dirname [info script]]
source $dir/createdb.tcl

# Populate some data to tables
if {[db "select count(*) from table1"] == 0} {source $dir/populate.tcl}

####################################################################
#
# Execution starts here
#

set tables [db tables]

foreach i $tables {
    # exclude system tables
    if {![string compare [lindex $i 3] TABLE]} {
	tclodbc::DumpTable db [lindex $i 2]
    }
}