Problem with Arduino YUN and MS SQL

Hello!!! I'm trying to conect the YUN to a MS SQL server data base. I have made this: http://forum.arduino.cc/index.php?topic=266549.msg1879526#msg1879526

I have installed freetds-dev.0.92.812. I had to install opkg install grep_2.14-1_ar71xx.ipk before.

But when I try to test tsql -C or tsql -H 192.168.0.111 -p 1433 -U sa -P password, the console shows:-ash: tsql: not found

root@YUNMaster1:/# tsql -c
-ash: tsql: not found

The tsql binary file is at path usr\local\bin

"make check" command says after a few minutes :

FAIL: t0001 FAIL: t0002 FAIL: t0003 FAIL: t0004 FAIL: t0005 FAIL: t0006 PASS: t0007 PASS: t0008 FAIL: dynamic1 PASS: convert FAIL: dataread FAIL: utf8_1 FAIL: utf8_2 FAIL: utf8_3 PASS: numeric PASS: iconv_fread FAIL: toodynamic PASS: challenge PASS: readconf PASS: charconv

FAIL: nulls

13 of 21 tests failed

See src/tds/unittests/test-suite.log

What's happening here? Thanks

Fitoduino: Hello!!! I'm trying to conect the YUN to a MS SQL server data base. I have made this: http://forum.arduino.cc/index.php?topic=266549.msg1879526#msg1879526

I have installed freetds-dev.0.92.812. I had to install opkg install grep_2.14-1_ar71xx.ipk before.

But when I try to test tsql -C or tsql -H 192.168.0.111 -p 1433 -U sa -P password, the console shows:-ash: tsql: not found

::::SNIP::::

The tsql binary file is at path usr\local\bin

::::SNIP:::: What's happening here? Thanks

Fitoduino, tsql is not in your ENVIRONMENT "PATH". At the command line type, $ env. You should see something like this:

USER=root
OLDPWD=/etc
HOME=/root
SSH_TTY=/dev/pts/0
PS1=\u@\h:\w\$ 
LOGNAME=root
TERM=xterm
PATH=/bin:/sbin:/usr/bin:/usr/sbin
SHELL=/bin/ash
PWD=/etc/config
SSH_CONNECTION=192.168.43.192 36309 192.168.43.237 22

You Can 1) Add the location of you file to the path. 2) Move the file to a directory in the path. 3) Call the file directly. example /usr/local/bin/tsql -H 192.168.0.111 -p 1433  -U sa -P password

Jesse

Make "/usr/local/bin" in $PATH

root@Arduino:~# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin
root@Arduino:~# export PATH=$PATH:/usr/local/bin
root@Arduino:~# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

make it conservative between boot, put them in /etc/profile.

nano /etc/profile

change from

export PATH=/bin:/sbin:/usr/bin:/usr/sbin

into

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

Thank you!!! :D :D :D

root@YUNMaster1:~# tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91.99
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: no
                        TDS version: 5.0
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: no

Hello again!!! I´d spended many hours with this project. Right now FreeTDS works properly and I can see the SQL database whit the console. I´m thinking to use a python script to connect de YUN whith a MS SQL database. I have tried pymssql , but the installation fails. Maybe I must use a cross compiler. I don´t know, but it´s a dificult way for me.

So I´ve tried pypyodbc +tdsodbc + unixodbc but there is no way. I can test the connection whith the isql command and it works right. But when I run the python code, the console shows the next menssage: pypyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified') There are a lot of people on the net whith the same problem... I've tried pypyodbc 1.3.3, pypyodbc 1.2.1 and pypyodbc 0.9.3.

Is there anybody who had made this?

My files are...

*************************************************
        /usr/local/etc/odbcinst.ini
[FreeTDS]
Description=v0.92 with protocol 8.0
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=1
**************************************************************
        /usr/local/etc/freetds.conf
TDS Version = 8.0
client charset = UTF-8

[Servidor]
host = 192.168.1.6
port = 1433
tds version = 8.0
# Added only
*************************************************************
        /usr/local/etc/odbc.ini
[sqlexpress]
Servername = sqlexpress
Driver = FreeTDS
TDS_Version    = 8.0
************************************************************
Test command: # isql -v sqlexpress YUNMaster1 12345678
****************************************************************
python code:
import pypyodbc                                                                                                                                             
import sys

#                  Get a connection to MSSQL ODBC DSN via pypyodbc, and assign it to conn
                                                                                                                                                            
while True:
        db = pypyodbc.connect('DSN=sqlexpress;UID=YUNMaster1;PWD=12345678')                                                                                                                                                                           
        cur = db.cursor()
                #                  Another change has been made. let that take effective, Now!
        cur.commit()
                #              I have done all the things, you can leave me and serve for others!
        cur.close()
        conn.close()
                                                                                            
        sys.exit(1)

Thanks!!

Fitoduino: ::::SNIP:::: But when I run the python code, the console shows the next menssage: pypyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified') ::::SNIP:::: Is there anybody who had made this?

@Fitoduino,

example on Internet shows different

connection_string ='Driver={SQL Server Native Client 11.0};Server=YOURSERVER;Database=YOURDATABASE;Uid=YOURUSER;Pwd=YOURPASSWORD;'

connection = pypyodbc.connect(connection_string)

You have not driver in your code. No server. No Database. Is example good? Test, let us know.

Jesse

Plan B:

check tsql source, modify it and compile C client.

Plan C:

JDBC connect with MSSQL

Plan D.

Use ash script and tsql for SQL communication

http://forum.arduino.cc/index.php?topic=206746.msg1524879#msg1524879

Thank you Jesse and sonnyyu. :) I've tested the pypyodbc's connection string example but it doesn't work. :'( I put the driver, server and database on the .ini files. Driver file; /usr/local/etc/odbcinst.ini

[FreeTDS]
Description=v0.92 with protocol 8.0
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=1

Connection file; /usr/local/etc/freetds.conf

#   $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".

# Global settings are overridden by those in a database
# server specific section
[global]
        # TDS protocol version
        TDS Version = 8.0
        client charset = UTF-8
[Servidor]
        host = 192.168.1.6
        port = 1433
        tds version = 8.0

DSN file; /usr/local/etc/odbc.ini

[sqlexpress]
Servername = Servidor
Driver = FreeTDS
TDS_Version    = 8.0

I think that all those files are right because I can connect using the next:

# isql -v sqlexpress YUNMaster1 12345678

I've tested a direct connection strings like the next:

connection_string ='Driver={/usr/local/lib/libtdsodbc.so};Server=192.168.1.6;Uid=YUNMaster1;Pwd=12345678;'

I always have the same message: :'(

Ipypyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified') leave pypyodbc at the moment.

Right now I'm working on plan C : the JDB connection. I'll tell you the results. :wink: