Re: [Lazarus] Handy script for Firebird users
And you didn't write it in Pascal because ? Joost Op woensdag 30-04-2008 om 11:28 uur [tijdzone +0200], schreef Graeme Geldenhuys: Hi, I created a script (Unix/Linux only at the moment) called 'mkdb' for use with our application deployment. We use the Firebird RDBMS and thought this might come in handy for others as well. It creates a Firebird database, creates the tables. Optionally it creates Views, applies table rights and inserts default data. All database information is read from sql script files: create.sql, views.sql, rights.sql, defaults.sql The script (mkdb) also takes three optional parameters: - database location - database username - database password I hope someone finds this useful. :) Regards, - Graeme - ___ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ platte tekst document bijlage (mkdb) #!/bin/sh # # Script to create a Firebird database, apply permissions and # to fill it with data. # # The script accepts optional arguments: #- A database to connect to. (default is setup below) #- Database username (default 'SYSDBA') #- Database password (default 'masterkey') # # The script looks for the following sql scrip files and executes them #- create.sql(mandatory) #- views.sql (optional) #- rights.sql(optional) #- defaults.sql (optional) # # Collect the database database=localhost:/home/graemeg/programming/data/m2empty.fdb #database=192.168.0.1:M2 if [ -n $1 ]; then database=$1 fi # Database login information user=SYSDBA if [ -n $2 ]; then user=$2 fi passwd=masterkey if [ -n $3 ]; then passwd=$3 fi # Choose one of the following: ISQL=isql -q -d $database -u $user -p $passwd #ISQL=/opt/firebird/bin/isql -q -d $database -u $user -p $passwd ## # # You shouldn't need to edit after this. # echo -n Creating the database $database ... ${ISQL} EOF set sql dialect 3; CREATE DATABASE $database; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi echo -n Creating the tables in database ... ${ISQL} EOF connect '$database' user '$user' password '$passwd'; input create.sql; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi if [ -e ./views.sql ]; then echo -n Creating the views in database ... ${ISQL} EOF connect '$database' user '$user' password '$passwd'; input views.sql; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi fi if [ -e ./rights.sql ]; then echo -n Applying table permissions ... ${ISQL} EOF connect '$database' user '$user' password '$passwd'; input rights.sql; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi fi if [ -e ./defaults.sql ]; then echo -n Inserting default data ... ${ISQL} EOF connect '$database' user '$user' password '$passwd'; input defaults.sql; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi fi # END ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
Joost van der Sluis wrote: And you didn't write it in Pascal because ? Joost Because the deployment PC's will not have FPC on them. Ummm... Then again, it takes all the parameters it needs for customization. Also, if I make it a console app, it will be cross-platform to. :) How to you handle standard input like was done in the script? copy- echo -n Creating the database $database ... ${ISQL} EOF set sql dialect 3; CREATE DATABASE $database; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi end- Regards, - Graeme - ___ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
2008/4/30 Graeme Geldenhuys [EMAIL PROTECTED]: Joost van der Sluis wrote: And you didn't write it in Pascal because ? Joost Because the deployment PC's will not have FPC on them. Ummm... Then again, it takes all the parameters it needs for customization. Also, if I make it a console app, it will be cross-platform to. :) How to you handle standard input like was done in the script? copy- echo -n Creating the database $database ... ${ISQL} EOF set sql dialect 3; CREATE DATABASE $database; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi end- it's just feeding the sql program a string (heredoc), then checking the result. you don't need to do anything special to transcribe this to pascal :) henry ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
On Wed, 30 Apr 2008, Graeme Geldenhuys wrote: Joost van der Sluis wrote: And you didn't write it in Pascal because ? Joost Because the deployment PC's will not have FPC on them. Ummm... Then again, it takes all the parameters it needs for customization. Also, if I make it a console app, it will be cross-platform to. :) How to you handle standard input like was done in the script? Use TProcess ? Michael. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
Graeme, For what it is worth, I think it is COOL!Having deployed FB on quite a few Linux servers, I can certainly see the benefit without question. Graeme, what is the largest FB concurrent user install you have running? My largest desktop application is 15 users. Can't tell you the count on web users. In almost 10 years of use, I've never had corruption either. The only things I do not like about FB is it lacks SSL, AutoIncrement attribute and Boolean fields. We've all managed to get by them, but I wish... :-) Great job on the utility! Tom Graeme Geldenhuys wrote: Hi, I created a script (Unix/Linux only at the moment) called 'mkdb' for use with our application deployment. We use the Firebird RDBMS and thought this might come in handy for others as well. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
This is off topic of course, but... You can use Generators (Sequences in other systems) joined to a trigger instead of AutoIncrement. You can simulate Boolean fields by creating a Domain. Leonardo M. Ramé http://leonardorame.blogspot.com Tom York escribió: The only things I do not like about FB is it lacks SSL, AutoIncrement attribute and Boolean fields. We've all managed to get by them, but I wish... :-) ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Handy script for Firebird users
Op woensdag 30-04-2008 om 13:13 uur [tijdzone +0200], schreef Graeme Geldenhuys: Joost van der Sluis wrote: And you didn't write it in Pascal because ? Joost Because the deployment PC's will not have FPC on them. Ummm... Then again, it takes all the parameters it needs for customization. Also, if I make it a console app, it will be cross-platform to. :) How to you handle standard input like was done in the script? I would simply use TSQLConnection.CreateDB to create a database, and the TSQLScript component to execute the scripts... copy- echo -n Creating the database $database ... ${ISQL} EOF set sql dialect 3; CREATE DATABASE $database; commit; EOF if [ ! $? = 0 ]; then echo Failed. else echo Done. fi end- Regards, - Graeme - ___ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus