Freetds Connection

C:\freetds-0.95rc2\bin>tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.95rc2
             freetds.conf directory: \freetds-0.95rc2\etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.0
                              iODBC: no
                           unixodbc: yes (unixODBC 2.3.2)
              SSPI "trusted" logins: yes
                           Kerberos: yes (Heimdal 1.6.99)
                            OpenSSL: yes (OpenSSL 1.0.2a)
                             GnuTLS: no

C:\freetds-0.95rc2\bin>tsql -H localhost -p 1433 -U sa -P master -D tempdb
locale is "English_United States.1252"
using default charset "UTF-8"
Setting tempdb as default database in login packet
.
.
.

This just seems to hang.  How do i get a prompt to allow me to run a query?
xoxomosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
I believe you use the wrong -H switch for the servername and the command should be rather like

tsql -S servername -U sa -P master

try that and leave the tempdb defualt outr for now. If servername is not recognized try the IP of your SQL Server and leave the port out unless your SQL is not running on default port 1433.

But...Do you really need to use freetds to run the queries? are you running them from a non Windows system against that SQL Server? If not, you should be able to use SQL own sqlcmd instead (or SSMS) like:

sqlcmd -U MyLogin -S <ComputerName>\<InstanceName>

http://www.sqlbook.com/SQL-Server/SQLCMD-command-line-utility-13.aspx
https://msdn.microsoft.com/en-CA/library/ms180944.aspx
0
xoxomosAuthor Commented:
I'm sure you're correct about not needing freetds to run queries.  My situation is i'm trying unsuccessfully to connect from a python program to SQLServer.  Some of the posts i've read leads me to believe i need a specific version of freetds to work on a python3/sqlserver connection.
0
xoxomosAuthor Commented:
C:\freetds-0.95rc2>cd bin

C:\freetds-0.95rc2\bin>tsql -S 134.154.228.217 -U sa -P master
locale is "English_United States.1252"
using default charset "UTF-8"
......still waiting.... :-(
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lcohanDatabase AnalystCommented:
so is this what you're using right?

http://www.freetds.org/userguide/python.htm

did you checked _mssql module?
http://pymssql.org/en/latest/_mssql_examples.html



Can you pl try just bel;ow and see if you get prompted for password?

tsql -H MSSQLServer -p 1433 -U sa


where "MSSQLServer" is your SQL Server COMPUTER(host) name - do not use localhost because that's not a valid SQL Server (service) name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xoxomosAuthor Commented:
Thanks.  Yes, i get prompt for password using either localhost, the machine ip or SQLExpress.


C:\freetds-0.95rc2>cd bin

C:\freetds-0.95rc2\bin>tsql -H localhost -p 1433 -U sa
Password: master

locale is "English_United States.1252"
using default charset "UTF-8"
^C
C:\freetds-0.95rc2\bin>tsql -H 134.154.228.217 -p 1433 -U sa
Password: thebes

locale is "English_United States.1252"
using default charset "UTF-8"
^C
C:\freetds-0.95rc2\bin>
C:\freetds-0.95rc2\bin>tsql -H MSSQLServer -p 1433 -U sa
Password: thebes

Error 20012 (severity 2):
        Server name not found in configuration files.
locale is "English_United States.1252"
using default charset "UTF-8"
Error 20013 (severity 2):
        Unknown host machine name.
There was a problem connecting to the server

C:\freetds-0.95rc2\bin>tsql -H SQLExpress -p 1433 -U sa
Password: thebes

locale is "English_United States.1252"
using default charset "UTF-8"
0
lcohanDatabase AnalystCommented:
you need to find the freetds.conf on that computer and need to put the apropriate values - see link below - in order to clear issues like "...Server name not found in configuration files."

http://pymssql.org/en/latest/freetds.html
0
xoxomosAuthor Commented:
From my .conf file.
# A typical Microsoft server
[SQLExpress]
      host = 134.154.228.217
      port = 1433
      # use ntlmv2 = yes
      encryption = request
      tds version = 8.0


Sorry, been away from this a while and thanks, I'm taking a second look at the link noticing
".....The system-wide FreeTDS configuration file is /etc/freetds.conf'.  I have my .conf file in c:\freetds\etc on windows and just now waking up to /etc is not the same as \etc .:-(
0
xoxomosAuthor Commented:
Tried copying .conf file directly onto c:\  with the same results.  Using SQLExpress, localhost, ipaddress, it finds something and hangs after accepting password.  Using another name, SQLServer, it knows there is no such instance period.
C:\freetds-0.95rc2\bin>tsql -H SQLExpress -p 1433 -U sa
Password: hebes

locale is "English_United States.1252"
using default charset "UTF-8"
^C
C:\freetds-0.95rc2\bin>^V
'▬' is not recognized as an internal or external command,
operable program or batch file.

C:\freetds-0.95rc2\bin>tsql -H MSSQLServer -p 1433 -U sa
Password:hebes

Error 20012 (severity 2):
        Server name not found in configuration files.
locale is "English_United States.1252"
using default charset "UTF-8"
Error 20013 (severity 2):
        Unknown host machine name.
There was a problem connecting to the server

C:\freetds-0.95rc2\bin>tsql -H localhost -p 1433 -U sa
Password: hebes

locale is "English_United States.1252"
using default charset "UTF-8"
Will try changing the version 8 to version 7.
0
xoxomosAuthor Commented:
Nope, do't think i should do that actually.
0
xoxomosAuthor Commented:
What should i be looking for once I enter the requested password?
0
xoxomosAuthor Commented:
One thing i'm noticing is when i run tsql -C the version comes out as 7 whereas the .conf file i have version set to 8.  Could this be part of the problem?

:\freetds-0.95rc2\bin>tsql -C
ompile-time settings (established with the "configure" script)
                           Version: freetds v0.95rc2
            freetds.conf directory: \freetds-0.95rc2\etc
    MS db-lib source compatibility: no
       Sybase binary compatibility: no
                     Thread safety: yes
                     iconv library: yes
                       TDS version: 7.0
                             iODBC: no
                          unixodbc: yes (unixODBC 2.3.2)
             SSPI "trusted" logins: yes
                          Kerberos: yes (Heimdal 1.6.99)
                           OpenSSL: yes (OpenSSL 1.0.2a)
                            GnuTLS: no


# Global settings are overridden by those in a database
# server specific section
[global]
    # TDS protocol version
      tds version = 8.0
      client charset = UTF-8
    dump file = C:\freetds-0.95rc2\etc\freeTDS.log
      text size = 64512

# A typical Microsoft server
[SQLExpress]
      host = 134.154.228.217
      port = 1433
      # use ntlmv2 = yes
      encryption = request
      tds version = 8.0
0
xoxomosAuthor Commented:
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _mssql
>>> conn = _mssql.connect(server='warehouse', user='sa', password='master!!', database='master')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_mssql.pyx", line 1887, in _mssql.connect (_mssql.c:19107)
  File "_mssql.pyx", line 632, in _mssql.MSSQLConnection.__init__ (_mssql.c:5880)
_mssql.MSSQLDriverException: Connection to the database failed for an unknown reason.
>>>
0
xoxomosAuthor Commented:
Looks like i will have to go with adding either unixODBC or IODBC into the mix with freetds.
Yes, my objective is to eventually run on OSX to SQLServer.
I believe the -H flag is for HOST and is ok.
0
xoxomosAuthor Commented:
Problem was 1433 was not the port sqlserver was running on.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.