source: trunk/data/konvert/postnas_0.6/datenbank_anlegen.bat @ 167

Revision 167, 3.3 KB checked in by astrid.emde, 12 years ago (diff)

bat zum Anlegen einer Datenbank mit Übergabe der Parameter

Line 
1@echo off
2REM ------------------------------------------------
3REM Konvertierung von ALKIS NAS-Format nach PosGIS -
4REM Teil 1: Eine neue PostGIS-Datenbank anlegen    -
5REM ------------------------------------------------
6REM
7REM Delete old Logfiles
8del ..\log_*.txt
9del ..\err_*.txt
10
11echo ==============================================================================
12REM Disclaimer
13echo.
14echo DISCLAIMER: PostNAS Skript zum Anlegen einer Datenbank. USE AT YOUR OWN RISK!
15echo Das Skript erzeigt eine Datenbank und spielt das PostNAS Schema ein
16echo
17echo.
18echo Voraussetzungen:
19echo - laufenden PostgreSQL 8.x Datenbank
20echo - Databankbenutzer mit Schreibzugriff
21echo - PATH Variable zu psql
22echo.
23echo Ist alles vorbereitet?
24echo Diese Argumente müssen übergeben werden:
25echo "%0 <HOST> <PORT> <DBNAME> <DBTEMPLATE> <DBUSER> <DropDB ja/nein>"
26echo.
27echo z. B.
28echo %0 %DBHOST% %DBPORT% alkis_import template_postgis alkis_user ja
29
30echo.
31echo ==============================================================================
32echo.
33REM 5 Params expected
34if not %5x==x goto ARGSSUPPLIED
35
36echo Continue?
37set /p PREPARED="(y)es or (n)o:"
38if %PREPARED%x==x goto :PREP
39
40if %PREPARED%==y goto :PREP_OK
41if %PREPARED%==n goto :End
42goto :PREP
43:PREP_OK
44
45:ARGSSUPPLIED
46set DBHOST=%1
47set DBPORT=%2
48set DBNAME=%3
49set DBTEMPLATE=%4
50set DBUSER=%5
51set DROPDB=%6
52echo.
53
54:CHOICES
55REM dbtype and encoding are fixed
56set USEDBTYPE=PostgreSQL
57set USEDBENC=UTF-8
58echo.
59echo Ihre Angaben:
60echo Databasetype: %USEDBTYPE%
61echo Encoding: %USEDBENC%
62echo Database Host: %DBHOST%
63echo Database Port: %DBPORT%
64echo Database Name: %DBNAME%
65echo Database Template: %DBTEMPLATE%
66echo Database User: %DBUSER%
67echo Datenbank %DBNAME% löschen: %DROPDB%
68echo.
69echo Installation starten?
70echo.
71rem delete ARG#5
72shift
73set /p START_INSTALL="(y)es or (n)o? "
74if %START_INSTALL%x==x goto CHOICES
75if %START_INSTALL%==y goto START_INSTALL
76goto PREP
77:START_INSTALL
78rem echo on
79
80:INSTPOSTGRESQL
81REM do these exist?
82psql --version 2> nul 1> nul
83if NOT %ERRORLEVEL% == 0 goto PGNOTFOUND
84
85if %DROPDB%==ja goto START_DROPDB
86if %DROPDB%==no goto START_CREATE
87goto :START_CREATE
88:START_DROPDB
89echo dropdb
90echo dropdb -U %DBUSER% -h %DBHOST% -p %DBPORT% %DBNAME%
91dropdb -U %DBUSER% -h %DBHOST% -p %DBPORT% %DBNAME%
92
93
94:START_CREATE
95echo creatingdb
96echo createdb -U %DBUSER% -h %DBHOST% -p %DBPORT% -T %DBTEMPLATE% -E UTF8 %DBNAME%
97createdb -U %DBUSER% -h %DBHOST% -p %DBPORT% -T %DBTEMPLATE% -E UTF8 %DBNAME%
98psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f alkis_PostNAS_0.6_schema.sql %DBNAME%  2>> ..\log_alkis_schema.txt
99psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f alkis_PostNAS_0.6_keytables.sql %DBNAME%  2>> ..\log_alkis_keytables.txt
100psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f nutzungsart_definition.sql %DBNAME%  2>> ..\log_alkis_nutzungsart_definition.txt
101psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f nutzungsart_metadaten.sql %DBNAME%  2>> ..\log_alkis_nutzungsart_metadaten.txt
102psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f gemeinden_definition.sql %DBNAME%  2>> ..\log_alkis_gemeinden_definition.txt
103psql -U %DBUSER% -h %DBHOST% -p %DBPORT% -f sichten.sql %DBNAME%  2>> ..\log_alkis_sichten.txt
104goto END:
105
106
107
108:PGNOTFOUND
109echo Sorry, psql not found, must be in PATH-Variable, exiting...
110goto END
111
112REM End, keep Terminal session open
113:END
114
115echo Die Datenbank wurde erzeugt. Prüfen Sie die Logdateien.
116echo.
117pause
Note: See TracBrowser for help on using the repository browser.