summaryrefslogtreecommitdiffstats
path: root/kexi/3rdparty/kexisql3/src/ksqlite2to3
blob: faa2f459bacc90a7520161cdb80536fa5019a028 (plain)
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
31
32
33
34
35
36
37
38
#!/bin/sh
#   This file is part of the KDE project
#   Copyright (C) 2004-2005 Jaroslaw Staniek <[email protected]>
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public
#   License as published by the Free Software Foundation; either
#   version 2 of the License, or (at your option) any later version.

# Performs migration from SQLite2 format to SQLite3 format
# usage: ksqlite2to3 <sqlite2-db-file>

if test $# -lt 1 ; then
	echo "usage: ksqlite2to3 <sqlite2-db-file>"
	exit 1
fi

basename=`basename $0`
temp=`mktemp -q "$basename"-XXXXXX 2> /dev/null || date +%y%m%d%H%M2`
dbfile=$1
dir=`dirname $dbfile`

ksqlite2 $dbfile .quit 2> /dev/null
if test $? -ne 0 ; then
	echo "This file is not in SQLite2 format"
	rm -f "$dir/$temp"
	exit 1
fi

ksqlite2 -verbose-dump $dbfile .dump | ksqlite "$dir/$temp"
if test $? -ne 0 ; then
	echo "Error during converting"
	rm -f "$dir/$temp"
	exit 2
fi

mv "$dir/$temp" $dbfile 2> /dev/null || exit 3