[unixODBC-dev] [DSN] create database

Carlo Cancellieri ccancellieri at hotmail.com
Thu Jul 29 13:01:08 BST 2010


Nick,
----------------------------------------
> Date: Thu, 29 Jul 2010 08:29:22 +0100
> From: nick at lurcher.org
> To: unixodbc-dev at mailman.unixodbc.org
> Subject: Re: [unixODBC-dev] [DSN] create database
>
> Carlo Cancellieri wrote:
>> Hi to all,
>> I'm coding a script to run some tests on my application and I'd like to create a new database but seams that I can't use isql to run a query without set a DSN. that's ok but why I've to set a database too?
>> -------------------------------odbc.ini
>> [PostgreSQL]
>> Description = Test to Postgres
>> Driver = /opt/unixodbc/lib/libodbcpsql.so
>> Trace = Yes
>> TraceFile = sql.log
>> ######################
>> #Database = SQLH <--------PROBLEM
>> ######################
>> Servername = localhost
>> UserName = postgres
>> Password = postgres
>> Port = 5432
>> Protocol = 6.4
>> ReadOnly = No
>> RowVersioning = No
>> ShowSystemTables = No
>> ShowOidColumn = No
>> FakeOidIndex = No
>> ConnSettings =
>> -----------------------------------------
>>
>> I want to create that database so how I can do this?
>> I've already tried to use a DSN without set the Database but this is what I get:
>> /opt/unixodbc/bin/isql -c -v PostgreSQL
>> [28000][unixODBC]FATAL: database "SQLH" does not exist
>> [ISQL]ERROR: Could not SQLConnect
>>
>> So the only way I found is :
>> 1 define a DSN connecting to the default postgres database,
>> 2 run the query CREATE DATABASE...
>> 3 exit
>> 4 configure a new DSN with the new database
>> 5 connect on the new database
>> 6 use it
>>
>> Is there a way to create the database before completely define a DSN?
>> If no, is there a way to query the DBMS to get a list of available database to configure (I know the postgres one but what about mysql? oracle? etc.)
>> any help is appreciated, thank you,
>> carlo cancellieri
>>
> Hi,
>
> I would say this is a question for the driver writers, its all in their
> domain. What happens if you set the DSN to connect to the default
> postgres database? Is that not what happens if you use createdb?
>
> --
> Nick

That's right but I've to write a script which don't know what type of DBMS is installed so...
it prompt to ask for:
  - a DBMS server, port, user, pass
- the path of the ODBC library used to connect

then it tries to create the DSN but DB are not included in templates so...
may I have to also ask for the default database?
I'd like to make my tests into an ad-hoc created database...
F.E. see: http://www.firebirdsql.org/manual/qsg10-creating.html

I want to know if it is possible using unixODBC:
- get a list of existing database making a query to the DBMS using it's ODBC library.
or
- (better) create a DB and then connect to it

For this operation should be sufficient to know:
- which odbc driver to use 
- server:port
- user
- password
Is this true? I really don't know, what do you think?
thank you,
carlo cancellieri
 		 	   		  


More information about the unixODBC-dev mailing list