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

Allow SQLDriverConnect instead of SQLConnect #9

Open
psykora opened this issue Jun 12, 2018 · 8 comments
Open

Allow SQLDriverConnect instead of SQLConnect #9

psykora opened this issue Jun 12, 2018 · 8 comments

Comments

@psykora
Copy link
Contributor

psykora commented Jun 12, 2018

Currently the ODBC connector is using SQLConnect which requires datasource to be defined in the system (Windows) or ini file (Unix).

It would be nice to be able to specify connection string during runtime. Something like this (example for MSSQL server)
Driver={SQL Server};Server=SERVER_HOSTNAME\INSTANCE;Database=DBNAME;Uid=DBUSER;Pwd=DBPASS;

@Erroneous1
Copy link
Owner

This looks like a great idea. Looking at the code, I think detail::connection_handle_t doesn't need any of the information that's only used for SQLConnect so there is a bit of work to be done there and then just add some alternate config structs and connection constructors. I might work on it this week.

I'll be adding constructors for SQLDriverConnect and SQLBrowseConnect.

@Erroneous1
Copy link
Owner

@psykora I made a branch feature/alternate_connects which adds driver_connection_config. Can you test it out to see if it works for you?

There are some breaking changes. ODBC_Type is now in sqlpp11::odbc instead of sqlpp11::odbc::connection_config. There isn't a connection_config.database anymore (I could add back in but it seems out of place, open for discussion). I need to work on CMake to get it to work better with sqlpp11 and date, maybe include both as subprojects.

@psykora
Copy link
Contributor Author

psykora commented Jun 13, 2018

@Erroneous1: Thanks! I didn't expect so prompt action. 👍
I am just experimenting with sqlpp11 and wanted to test it with MSSQL. I noticed your odbc connector and hardly managed to build master with visual studio 2017 15.6 and now my cmake parameters are not working again :). Any reason why is it is not based on master?

@psykora
Copy link
Contributor Author

psykora commented Jun 14, 2018

@Erroneous1 I cherry-picked your commit into master and the driver connection works great!

@psykora
Copy link
Contributor Author

psykora commented Jun 14, 2018

Btw. here is what I had to change to pass compilation under MSVC 2017 15.6
psykora@14d2aa7

my cmake configure command:
cmake .. -DCMAKE_PREFIX_PATH=C:\work\inst -DHinnantDate_ROOT_DIR=C:\work\inst\date_prj -DCMAKE_INSTALL_PREFIX=C:\work\inst\sqlpp11-connector-odbc

@Erroneous1
Copy link
Owner

Erroneous1 commented Jun 14, 2018 via email

@Erroneous1
Copy link
Owner

Ok try out feature/SQLDriverConnect instead. This is modified from master instead of an old branch. I am also making giving it a string reference optional since you don't need it if you know the config is correct anyway.

@psykora
Copy link
Contributor Author

psykora commented Jun 21, 2018

It works well, I will send you several pull requests and you can check whether it still compiles with clang. I am compiling with MSVC and some of the changes are necessary to pass compilation.
Thanks!

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