Connect Raspberry Pi to SQL Server using pyodbc error: [08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect) - sql

I'm trying to connect a raspberry pi 3 to a local SQL Server.
I did this:
sudo apt-get install unixodbc
sudo apt-get install unixodbc-dev
sudo apt-get install freetds-dev
sudo apt-get install tdsodbc
sudo apt-get install freetds-bin
sudo pip3 install pyodbc
sudo apt-get install python-pyodbc
sudo nano /etc/freetds/freetds.conf
Added this block
[sqlserver]
host = 192.168.0.109 # Sql Server's IP addr
port = 1433 # default
tds version = 7.0 #
instance = Database1 # Database name
now in /etc/odbcinst.ini
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Setup = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
UsageCount = 1
and in /etc/odbc.ini file as follows:
[NAME1]
Driver = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Description = MSSQL Server
Trace = No
Server = ServerName1
Database = Database 1
Port = 1433
TDS_Version = 7.4
when I run
tsql -S sqlserver -U username
I can connect t the database and run queries, but When I try
tsql isql NAME1 user 'password'
I get
[ISQL]ERROR: Could not SQLConnect
I got a python script with
class SQL:
cnxn = None
cursor= None
def __init__(self):
try:
self.cnxn = pyodbc.connect('DRIVER={FreeTDS}; SERVER= ws2016_01; DATABASE=databasename; UID=user; PWD=password;TDS_Version=7.2;')
self.cnxn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
self.cnxn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
self.cnxn.setencoding(encoding='utf-8')
And I keep getting the error
[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)
Thanks for reading, any help would be deeply appreciated!

Related

error in installing my_sql on AWS EMR cluster

I'm trying to start up MYSQL on my EMR cluster but it's showing as ERROR 1045 (2800): Access denied as shown in picture posted . Wat should i do ?ERROR
After executing these commands :
wget https://de-mysql-connector.s3.amazonaws.com/mysql-connector-java-8.0.25.tar.gz
tar -xvf mysql-connector-java-8.0.25.tar.gz
cd mysql-connector-java-8.0.25/
sudo cp mysql-connector-java-8.0.25.jar /usr/lib/sqoop/lib/
I tried setting password of database but it wasn't connecting to it .
it took my 3 days for getting how to install mysql on EMR
Install MySQL using the following command:
sudo yum install mysql-server -y
Start the MySQL service using the following command:
sudo service mysqld start
Set a root password for MySQL using the following command:
sudo mysqladmin -u root password yourpassword
Optionally, you can secure your MySQL installation by running the secure installation script using the following command:
sudo mysql_secure_installation
This script will prompt you to set the root password, remove anonymous users, disallow root login remotely, remove the test database, and reload the privilege tables.

Problems with Odoo v12 installation

I need to install Odoo V12 in my laptop and I having some problems with it.
When I run the ./odoo-bin command for running the server this is the log.
It seems okey but when I run http://localhost:8069/ is not working.
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/core/addons,/opt/odoo/core/odoo/addons
xmlrpc_port = 8269
Postgres user list:
Anyone knows what's happening?
Thanks for reading!
Check if db is working and permission on config file.
sudo chown odoo: /etc/odoo-server.conf
sudo chmod 640 /etc/odoo-server.conf
actually problem is with process's pid.
You have to kill process which is running on localhost:8069 port.
fire this commands:-
ps aux|grep odoo
Their find your command like (ODOO_FOLDER_PATH/odoo-bin )
Kill this process with
sudo kill -9 pid(pid is the process id , find where you located the line : second column)

ERR_EMPTY_RESPONSE for localhost when running Docker

Here's my Dockerfile:
# CentOs base image
FROM centos:centos6.8
# install python, pip, apache and other packages
RUN yum -y update; yum clean all
RUN yum -y install epel-release; yum clean all
RUN yum -y install centos-release-scl; yum clean all
RUN yum -y install python27; yum clean all
RUN yum -y install python-devel.x86_64; yum clean all
RUN yum -y install python-pip; yum clean all
RUN yum -y install gcc; yum clean all
RUN yum -y install httpd httpd-devel mod_ssl; yum clean all
# Make a non root user so I can run mod_wsgi without root
# USER adm
# install Python modules needed by the Python app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt
# copy files required for the app to run
COPY . /usr/src/app/
# tell the port number the container should expose
EXPOSE 80
# run the application
# CMD ["mod_wsgi", "start-server run_apache_server.wsgi"]
# CMD ["cat", "/etc/passwd"]
# CMD ["cat", "/etc/group"]
# CMD ["find", "/"]
CMD ["/bin/sh", "-c", "/usr/bin/mod_wsgi-express start-server run_apache_server.wsgi --user adm --group apache"]
I can run the app:
$ docker run -d -P --name myapp jacobirr/pleromatest
And see tcp port 80:
$ docker port myapp
80/tcp -> 0.0.0.0:32769
Here's my requirements.txt:
Flask==0.10.1
Flask-Restless==0.13.1
Flask-SQLAlchemy==0.16
Jinja2==2.7
MarkupSafe==0.18
SQLAlchemy==0.8.2
Werkzeug==0.9.2
gunicorn==17.5
itsdangerous==0.22
mimerender==0.5.4
python-dateutil==2.1
python-mimeparse==0.1.4
requests==1.2.3
six==1.3.0
wsgiref==0.1.2
setuptools==5.4.2
mod_wsgi==4.5.15
Why can't I get to localhost:32769 in the browser? I suspect this is related to:
•the user/group running apache?
•the fact that I'm installing mod_wsgi but it's nowhere on the docker "filesystem" so I have to use mod_wsgi-express?
Update:
'1' Netstat shows:
[root#9003b0d64916 app]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:irdmi *:* LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 113181 /tmp/mod_wsgi-localhost:8000:0/wsgi.1.0.1.sock
'2' httpd seems to be running in my container:
[root#9003b0d64916 mod_wsgi-localhost:8000:0]# ps aux | grep httpd
root 1 0.0 0.2 64060 5084 ? Ss 21:17 0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm 6 0.0 0.6 350928 13936 ? Sl 21:17 0:00 (wsgi:localhost:8000:0) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm 7 0.0 0.1 64192 3248 ? S 21:17 0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
From all your outputs, your httpd / uwsgi process is definitely bound to 8000, and this is the port you need to expose on the container.
This line in netstat, is showing a bind on 8000, and nothing else.
tcp 0 0 *:irdmi *:* LISTEN
It is not obvious here, but if you use the --numeric-ports argument, it will not convert the 8000 into its known port.
In your docker file, again you should
EXPOSE 8000
When launching your container, you can also specify the port to use on the host machine:
docker run -p 8080:8000 --name ...
After this, you should be able to use your browser to hit
localhost:8080 -> container:8000
Add this to your Dockerfile, just before CMD:
WORKDIR /usr/src/app/
Assuming that your start-apache-server file is in that directory. This will help wsgi to find the needed file.

Unable to get data from PostgreSQL using mod_lua

This is my setup:
OS: Linux Ubuntu 14.04 64bit
DB: Postgres 9.4 (installed from official Postgres repo)
Apache: 2.4.7 with mod_lua manually compiled from source in Apache 2.4.20 and installed
Database init script is as follows:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
client VARCHAR(20) NOT NULL UNIQUE,
secret VARCHAR(20) NOT NULL
);
INSERT INTO users(client, secret) VALUES('john' , 'john' );
INSERT INTO users(client, secret) VALUES('apple', 'orange');
INSERT INTO users(client, secret) VALUES('kiwi' , 'pear' );
INSERT INTO users(client, secret) VALUES('peach', 'berry' );
Apache has enabled mod_dbd that is configured as follows:
<IfModule dbd_module>
DBDriver pgsql
DBDPersist on
DBDMax 20
DBDParams "host='localhost' port='5432' dbname='demousers' user='postgres' password='postgres'"
DBDPrepareSQL 'SELECT u.secret FROM users u WHERE u.client=%s' client_secret
</IfModule>
There is also mod_lua which is configured like this:
<IfModule lua_module>
LuaRoot /vagrant/luatest
LuaScope thread
LuaCodeCache stat
LuaHookAccessChecker /vagrant/luatest/cookie_handler.lua handler early
LuaHookAccessChecker /vagrant/luatest/handler.lua handler late
</IfModule>
This is the sample code that I'm trying to execute in handler.lua that fails:
require "string"
require "apache2"
local inspect = require "inspect"
function handler(r)
local db, err = r:dbacquire()
if not db then
r:debug("[500] DB Error: " .. err)
return 500
end
r:debug("Acquired database")
local statement, errmsg = db:prepared(r, "client_secret")
if not statement then
r:debug("[500] DB Error: " .. errmsg)
db:close()
return 500
end
r:info("Acquired prepared statement")
local secret
local result, emsg = statement:select("john")
if not emsg then
r:info("Fetch rows")
local rows = result(0, true)
r:debug("Rows " .. inspect(rows))
for k, row in pairs(rows) do
r:info("Pass " .. k .. inspect(row))
if row[1] then
secret = string.format("%s", row[1])
end
end
else
r:debug( "Error : " .. emsg)
end
db:close()
return 403
end
Looking at the postgres sql log I see that the query was correctly executed and parameter passed. The issue is that I get the record that has no values just nil placeholders in lua table - rows is like this
{ {} }
So, is this a bug or my mistake?
Unfortunately it is a bug. For details see:
https://bz.apache.org/bugzilla/show_bug.cgi?id=56379
This is the solution that fixes the problem
# Install Apache 2.4.10 from backports repo that has working mod_lua
sudo apt-get install -y -t trusty-backports apache2 apache2-dev apache2-utils
sudo apt-get install -y libaprutil1-dbd-pgsql
# Install lua dependencies
sudo apt-get build-dep -y lua5.1
sudo apt-get install -y lua5.1
sudo apt-get install -y liblua5.1-0-dev
# Get the source code
APACHEVER='2.4.10'
cd /tmp/
apt-get source -y apache2="$APACHEVER"
mv "apache2-$APACHEVER/modules/lua/lua_dbd.c" "apache2-$APACHEVER/modules/lua/lua_dbd.c_original"
# Applying the patch for https://bz.apache.org/bugzilla/show_bug.cgi?id=56379
# without it dbd + lua + postgres do not work - you need to previously prepare the patched c file
cp -u /vagrant/lua_dbd.c "apache2-$APACHEVER/modules/lua/"
cd "apache2-$APACHEVER/modules/lua"
# Build and install patched lua module
sudo apxs -I/usr/include/lua5.1 -cia mod_lua.c lua_*.c -lm -llua5.1
sudo service apache2 restart

I would like to set up rfc5766-turn-server in Ubuntu 14.04, can anyone give me the set of steps listed all together ? I am doing it in AWS EC2

I have tried to install and set up rfc5766-turn-server in AWS EC2 but unable to do it as I do not see a proper flow of work or command line for that, can someone help me about this ? I need to set it up in Ubuntu 14.04
do an ssh login to your ec2 instance, then run the below commands for installing and starting the turn server.
commands for installing turnserver:
sudo apt-get update
sudo apt-get install make gcc libssl-dev libevent-dev wget -y # for installing modules required by turn server
mkdir ~/turn && cd ~/turn # creating temp directory
wget turnserver.open-sys.org/downloads/v3.2.5.9/turnserver-3.2.5.9.tar.gz # downloading the TURN source code
tar -zxvf *.gz # extract
cd turn*
make
sudo make install # installing the rfc5766
cd ../.. && rm -rf turn # cleaning up
command for starting the TURN server:
turnserver -a -o -v -n -u user:root -p 3478 -L INT_IP -r someRealm -X EXT_IP/INT_IP
assumptions:
your ip, internal ip = EXT_IP, INT_IP
desired port for listening: 3478
single credential username:password = user:root
realm: someRealm
in your WebRTC app, you can use trun server like:
{
url: 'turn:user#EXT_IP:3478',
credential: 'root'
}