Archive: Create database with NSIS


Create database with NSIS
Hello there,
I am trying to create a database with NSIS. I have SQLmetadata.txt file and i want to create a database from this metadata. I would like to use iboConsole database motor to run my database. So is it possible to create a database from metadata with NSIS? Please help.


Hi,
I never used iboConsole but i use PostgreSql and i think it may be same behavior.

Install the database motor then use command batch to create database and then load the SQLmetadata.txt file into it.

it's how i proceed.

Guillaume


Hi, Anybody has any idea how can i create database with NSIS by using Firebird isql.exe?


Firebird database is a single .fdb/.gdb file so you can create it and pack with NSIS or you can create it by your application on first run.


Is it possible to create database by NSIS installer? Please help.


please see my previous post


You can use the plugin ExecDos for this:


ExecDos::exec "[firebird_dir]\bin\isql.exe" "create database C:\test.gdb;\nexit;\n"

The second parameter sends the several commands to the isql tool as if you where typing it in the console app (\n stands for a carriage return or Enter)

Regards,
JP

I use this:
ExecWait '"C:\Program Files\Firebird\Firebird_2_1\bin\isql.exe" "CREATE DATABASE c:\database.FDB; user SYSDBA password agripomo page_size 16384 default character set ISO8859_1;\nexit;\n"'

Can you help me find the problem this. because when I run this i get error like "Statement failed, SQLCODE = -902
Unable to complete network request to host "CREATE DATABASE c".
-Failed to locate host machine.
-The specified name was not found in the hosts file or Domain Name Services.
Use CONNECT or CREATE DATABASE to specify a database
SQL>

can you help please.
I tried your code aslo i get the same error.
I tried to run with ExecDos::exec and it i can't compile NSIS and gives error "invalid command"


Try a double slash in the filename ,e.g. c:\\database.FDB


I tried but no luck.
Does NSIS understand SQL commands?


NSIS doesn't have to understand SQL commands, it passes the commands as strings to the isql tool.
It seems like the commandstring is truncated at the semicolon, I'm not sure why.
What happens when you use "CREATE DATABASE database.FDB;"?


i get same error and command prompt just bling and disappear. doesn't make database.It looks like i am so stuck.


can anyone help me about avobe mentioned problem.


OK, I checked, and this should work:

ExecDos::exec "C:\Program Files\Firebird\Firebird_2_1\bin\isql.exe" "CREATE DATABASE 'c:\database.FDB';$\nuser SYSDBA password agripomo page_size 16384 default character set ISO8859_1;$\nexit;$\n"

- Don't place single quotes before and after the complete ExecDos Command
- You forgot the \n between the CREATE DATABASE and user SYSDBA commands
- Use $\n instead of \n
- Place single quotes before and after the database filename

Thanks very much i proceed with my scripts by your great help. Thanks again.


ExecDos::exec "$folder\bin\isql.exe" "CONNECT '127.0.0.1:$desfolder\database.fdb' user '$login' password '$password' && INPUT '$source';$\nexit;$\n"
Do you think this is the right way to input metadata to to database. Please help.


To input metadata data you can use the commandline directly:

ExecDos::exec "$folder\bin\isql.exe -i '$source' '127.0.0.1:$desfolder\database.fdb' -user '$login' -pass '$password'"

It worked so perfact. thanks.
I have one SQL file which i should input also in the database. But i learn that from u. Now the question is that is it possible to put variable to that SQL file before i input that file to the database? For ex. in the SQL file there is "ContractorID" where i should put a number. So the idea is that when i create a database for new Contractor i need to put the contractorID in the SQL file and input to the data base. So my idea is that "if possible" i want that NSIS script will ask the CntractorID and send it to SQL file and input that file to the database. I am sorry that asking too many question. thanks for prevous help.


It worked so perfact. thanks.
I have one SQL file which i should input also in the database. But i learn that from u. Now the question is that is it possible to put variable to that SQL file before i input that file to the database? For ex. in the SQL file there is "ContractorID" where i should put a number. So the idea is that when i create a database for new Contractor i need to put the contractorID in the SQL file and input to the data base. So my idea is that "if possible" i want that NSIS script will ask the CntractorID and send it to SQL file and input that file to the database. I am sorry that asking too many question. thanks for previous help.


Hi Rusell,

you can use the TextReplace plugin for that:
http://nsis.sourceforge.net/TextReplace_plugin

Regards,
JP


Hello,
thanks for help.


it looks like that if the "source" or "destination" folder is for example: 'C:\program files\folder\database.fdb' isql doesn't except space between 'program and file'. I think you know how to overcome this problem. please help. thanks.


try:

ExecDos::exec "$folder\bin\isql.exe -i $\"$source$\" $\"127.0.0.1:$desfolder\database.fdb$\" -user '$login' -pass '$password'"

($\" results in a " for isq.exe)

thanks very much.


changing the password
hi,

I have one database in my application path, whether can i change password for that using NSIS script. I know the previous password of the database.

help me.


This is not a NSIS question, but a firebird question.
See the Quickstart manual, chapter "Server configuration and management"