Rails + SQL Server: what to add to a .yml database?

I am trying to connect Rails to SQL Server. I installed activetecord-sqlserver-adapter and ruby-odbc gems, but I'm not sure what to add to my database.yml file.

What is DSN and why do I need it? (Is this some kind of feature for Windows?)

What if I want to use Windows authentication instead of specifying a username and password?

I tried to create a DSN by specifying Windows NT authentication and putting the following in my config.yml:

development:
  adapter: sqlserver
  dsn: myDsn
  mode: odbc

but I get "The specified DSN contains an architecture mismatch error between the driver and the application." [I tried to create a DSN from Windows / system32 / odbcad32.exe since a google search said it would create a 32-bit DSN instead, but I get the same error.]

Am I missing something in my database.yml file?

UPDATE: I tried to use

development:
  adapter: sqlserver
  mode:odbc
  dsn: Provider=SQLOLEDB; Data Source=.\SQLEXPRESS; Integrated Security=SSPI

but I get the message "Data source name not found and not specified by default." Is it possible that my provider is not SQLOLEDB? [I don’t know what the provider is or how to find out what it is - I just copied it from another connection string that I found.] I know that I can connect to. \ SQLEXPRESS using Windows authentication from my actual program SQL Server Management Studio.

+3
source share
1 answer

DSN is the "Database Source Name". It contains information that the ODBC driver should connect to a specific database.

, SO Q & A : rails SQL Server 2005 Windows

. connectionstrings.com .

+2

Source: https://habr.com/ru/post/1766822/


All Articles