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

Support for MSSQL #66

Closed
faustinoaq opened this issue Jul 28, 2017 · 7 comments
Closed

Support for MSSQL #66

faustinoaq opened this issue Jul 28, 2017 · 7 comments

Comments

@faustinoaq
Copy link

Hi, currently, MSSQL is available on Linux and is pretty easy to use via docker.

I found nothing related to how connect Crystal to Microsoft SQL Server.

Is possible to create an adapter for MSSQL?

@bcardiff
Copy link
Member

There is no current option for mssql.
A driver would need to either:

  1. implement binding to http://www.freetds.org/ (https://github.com/rails-sqlserver/tiny_tds might serve for inspiration), or

  2. implement the https://msdn.microsoft.com/en-us/library/dd304523.aspx protocol directly to the socket as crystal-pg and crystal-mysql

@Virtual-Machine
Copy link

This is literally the only thing holding me back from using Crystal in production at work. I have several legacy databases I need to support that are in MSSQL. Lacking the MSSQL driver is forcing me to use Golang which is ok but I would definitely prefer to be using Crystal. Especially when it comes to the database api, I think Crystal offers much nicer syntax compared to Go.

I looked into pulling fresh nightly copies of data from MSSQL to MYSQL but inevitably someone complains about stale data and its too costly to be pulling the full set more frequently during the day. I am no expert but could I possibly link the MSSQL and MYSQL databases and then query out the MSSQL data through MYSQL or do linked servers not function the way I am expecting?

@faustinoaq
Copy link
Author

Crystal on Windows is in progress, so, I think a MSSQL binding would be useful, I will try to do something. 😄 (I hope keep my smile)

@fridgerator Did you try to create a MSSQL binding before? how was that?

@fridgerator
Copy link
Contributor

@faustinoaq No I never tried to do it in crystal. I recently had to connect a rails app to a legacy MSSQL server, and used tiny_tds (mentioned above). It was an unpleasant experience.

@wonderix
Copy link
Contributor

wonderix commented Nov 15, 2020

Implementing a binding to freetds will not work, because a call to the library will block all fibers in crystal. The ruby binding is using rb_thread_call_without_gvl to release the global interpreter lock. This will not be possible in crystal.
The only possibility would be to implement the protocol directly. Perhaps jtds could be a starting point.

@bcardiff
Copy link
Member

Even though I would encourage a protocol implementation directly, I'm not convinced that freetds can't be wrapped.

It is possible to have a dedicated thread to handle the calls to the library if that is needed by freetds. I did something like that in https://github.com/bcardiff/crystal-fswatch. I am not familiar with freetds though.

@wonderix
Copy link
Contributor

I started with an implementation of tds in plain crystal

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

No branches or pull requests

5 participants