Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to support create/drop a database. #45

Closed
tredoe opened this issue Nov 13, 2019 · 13 comments
Closed

Request to support create/drop a database. #45

tredoe opened this issue Nov 13, 2019 · 13 comments

Comments

@tredoe
Copy link

tredoe commented Nov 13, 2019

Please, could you to add support to create and drop a database with db.Exec() API?

Thanks in advance!

@akhilravuri1
Copy link
Contributor

Hi @tredoe
Our driver is based on the go standard package database/sql.
As of now, database package does not support create a database (admin operation) so we cannot support it.

If go add's support for creating a database. we will also support that.

Thanks,
Akhil.

@tredoe
Copy link
Author

tredoe commented Nov 13, 2019

I can create databases using the package database/sql at other DBMSs like Mysql, PostgreSQL, MariaDB, and Microsoft SQL Server (it's that I've tested until now).

By now, only fails with IBM DB2. The next ones to testing are Oracle and Firebird. So it is not an issue related to the support at database/sql.

To create a database, there is to connect to the master database and then to send a statement like 'CREATE DATABASE [name]'.

@akhilravuri1
Copy link
Contributor

I can create databases using the package database/sql at other DBMSs like Mysql, PostgreSQL, MariaDB, and Microsoft SQL Server (it's that I've tested until now)

Can you send me the GitHub links of these drivers?

@tredoe
Copy link
Author

tredoe commented Nov 13, 2019

MySQL/MariaDB: "github.com/go-sql-driver/mysql"
PostgreSQL: "github.com/lib/pq"
SQL Server: "github.com/denisenkom/go-mssqldb"

In fact, I could add the code where it shows how I create a database. MySQL or PostgreSQL?

@akhilravuri1
Copy link
Contributor

akhilravuri1 commented Nov 13, 2019

Hi @tredoe
In IBM db2 to create a database, you have to disconnect from the database.
image

And in the go-driver, we can add that support if you are not connecting to the database.

Thanks,
Akhil

@akhilravuri1 akhilravuri1 reopened this Nov 13, 2019
@akhilravuri1
Copy link
Contributor

could you to add support to create and drop a database with db.Exec() API?

@tredoe we cannot add a create database with db.Exec() but we can try to add this support with a new api.
Sample:-

import 'github.com/ibmdb/go_ibm_db'
func main(){
//connection string without database name.
go_ibm_db.CreateDB('databasename', 'host=localhost;uid=uname;pass=password,port=40000')
}

@tredoe
Copy link
Author

tredoe commented Nov 13, 2019

It is not necessary to add a new API.

If the connection string has the key 'Database', then it connect to such DB, else it connects to the instance where we could send a statement like "CREATE DATABASE".

@akhilravuri1
Copy link
Contributor

akhilravuri1 commented Nov 13, 2019

If the connection string has the key 'Database', then it connect to such DB, else it connects to the instance where we could send a statement like "CREATE DATABASE".

@tredoe
Are you talking about IBM DB?
Did you pass the connection string(like datbase, host, uid, port, pass) or dsn=name?

@tredoe
Copy link
Author

tredoe commented Nov 13, 2019

I'm talking about IBM DB2, and I used the string "Hostname=127.0.0.1;Protocol=tcpip;Port=50000;Database=%s;Uid=%s;Pwd=%s".

It was only an idea to not have to add a different API.

@akhilravuri1
Copy link
Contributor

I'm talking about IBM DB2, and I used the string "Hostname=127.0.0.1;Protocol=tcpip;Port=50000;Database=%s;Uid=%s;Pwd=%s".

It was only an idea to not have to add a different API.

Our clidriver does not work in that way...It uses different api to create a database.

Create database is admin operation.

@tredoe
Copy link
Author

tredoe commented Nov 16, 2019

With Oracle there is also to use a command to create a database (sqlplus; db2 for IBM2), so there is no need to change the API on this driver. Those DBMSs work of that way and there is no need to change the API to be enable to create/drop a database.

Thanks anyway!

@tredoe tredoe closed this as completed Nov 16, 2019
@akhilravuri1
Copy link
Contributor

akhilravuri1 commented Nov 18, 2019

Hi @tredoe

I don't know how oracle handles 'create database' query but in our db2 you have to call a new api to create the database, not the exec api.

You can check this documentation where we support create and drop database API's.
https://github.com/ibmdb/node-ibm_db/blob/master/APIDocumentation.md#createDbSyncApi

we have taken your request to support create and drop database api but it will be supported in the same way how node js supports.

Thanks,
Akhil

@tredoe tredoe reopened this Nov 18, 2019
@akhilravuri1
Copy link
Contributor

Hi @tredoe

Database creation support has been added. Please pull the latest code and use it.

Thanks,
Akhil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants