After installing Superset (open source software from Airbnb) on my virtual machine (RHEL, Linux 7.2-11), I cannot add my MSSQL database in the configuration page.
Menu->Sources->Databases->Add
In the SQLAlchemy URI field, I entered :
mssql+pymssql://user:password#host:port/database
Obviously, with my user, password, host, port and database name.
But when I click "Test Connection" I have the following error :
ERROR: {"error": "Connection failed!
The error message returned was:
(pymssql.OperationalError) (18456, 'DB-Lib error message 20018, severity 14:\
General SQL Server error: Check messages from the SQL Server\
DB-Lib error message 20002, severity 9:\
Adaptive Server connection failed (host:port)')"}
I already installed the pymssql package and I do not really know where this error could come from.
I tried to follow these tutorials but, maybe I'm doing it wrong:
http://airbnb.io/superset/installation.html
http://airbnb.io/superset/tutorial.html#connecting-to-a-new-database
What worked for me is the following:
mssql+pymssql://user:pass#address.of.db/?charset=utf8
However, I didn't manage to define a database using this syntax, and in turn couldn't define/find the available tables.
I was also having problem to connect with MSSQL. I was on macOS Catalina. I took the following steps, and it worked:
brew install msodbcsql17 mssql-tools (see: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15)
pip install pyodbc
mssql+pyodbc://UserName:Password#HostIP,Port/DBName?driver=ODBC Driver 17 for SQL Server
Mentioning of 'driver=ODBC Driver 17 for SQL Server' in the end is important. (See: https://stackoverflow.com/a/51266453/13150101)
Please try mssql://user:password#host:port/database
Related
I would like to connect to my MariaDB10 database in a Synology NAS using python SQLalchemy. I installed PhpMyAdmin, and created a database named "test", and a random table called "company". I inserted a few rows of dummy data in the table already through the interface. Here is a snapshot of it.
My code is like this:
# Module Imports
import sqlalchemy
import pymysql
from sqlalchemy.ext.declarative import declarative_base
import config_maria_us
# Define the MariaDB engine using MariaDB Connector/Python
user = "username"
passwd = "password"
host = "192.168.1.111"
db = "test"
port= "3307"
engine = sqlalchemy.create_engine(f'mysql+pymysql://{user}:{passwd}#{host}:{port}/{db}')
sql_df = engine.execute("SELECT * FROM company" ).fetchall()
But this returns an error:
OperationalError: (2003, "Can't connect to MySQL server on '192.168.1.111' ([Errno 61] Connection refused)")
Because of this page, so I keep using create_engine("mysql+pymysql:. It says to connect to a MariaDB database, no changes to the database URL are required.
I followed this page, and tried to install mariadb SQLAlchemy by brew install mariadb SQLAlchemy. But it shows a warning Warning: No available formula with the name "sqlalchemy". Did you mean sqlancer?
Then I ofcourse installed MariaDB Connector/C (by following this page) with brew install mariadb-connector-cand installed PyMySQL with pip install PyMySQL. Actually, to start with, i tried to installed mariadb with brew install mariadb, but after loading a pile of things, it shows failure,
Error: Cannot install mariadb because conflicting formulae are installed.
mysql: because mariadb, mysql, and percona install the same binaries
Please `brew unlink mysql` before continuing.
Unlinking removes a formula's symlinks from /opt/homebrew. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.
I did not go on installing it, because i don't know how to "relink" MySQL after the unlink.
That's pretty much it, would anyone please tell me what to do? by running the "engine = ..." syntax, it looks like i at least reached my server, but it still fail to connect as '(pymysql.err.OperationalError) (2003, "Can't connect to MySQL server'
OP probably resolved by himself/herself but in case someone else still face the similar issue. In my case, after following steps, I can have access from python script to mariadb hosted in NAS.
Make sure MariaDB turn on TCP/IP Connection
Make sure your username from working machine IP has permission to the database. You can set this up by
GRANT ALL PRIVILEGES ON database_name.* TO 'username'#'localhost';
I was trying to connect oracle database using python like below.
import cx_Oracle
conn = cx_Oracle.connect('user/password#host:port/database')
I've faced an error when connecting oracle.
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help.
I've been struggling to figure it out. I used my user name, password, host, port and database('orcl') for example,
'admin/admin#10.10.10.10:1010/orcl'.
Why coudn't it connect?
Ahh, btw I'm running all the code in azure notebooks.
That error indicates that you are missing a 64-bit Oracle client installation or it hasn't been configured correctly. Take a look at the link mentioned in the error message. It will give instructions on how to perform the Oracle client installation and configuration.
[Update on behalf of Anthony: his latest cx_Oracle release doesn't need Oracle Client libraries so you won't see the DPI-1047 error if you upgrade. The driver got renamed to python-oracledb but the API still supports the Python DB API 2.0 specification. See the homepage.]
This seems a problem with version 6.X.This problem didnot appeared in 5.X.But for my case a little workaround worked.I installed in my physical machine and only thing that i need to do was a pc reboot or reopen the terminal as i have added in the path of environment variables.You can try to install in physical machine instead using azure notebooks.
This error come when your Oracle Client is not installed or LD_LIBRARY_PATH is not set where libclntsh.so is present.
if you have Oracle client installed then search for libclntsh.so and set the LD_LIBRARY_PATH as
"export LD_LIBRARY_PATH=/app/bds/parcels/ORACLE_INSTANT_CLIENT/instantclient_11_2:$LD_LIBRARY_PATH"
Here is the full program to connect Oracle using python.
First, you need to install cx_Oracle. to install it fire the below command.
pip install cx_Oracle
import cx_Oracle
def get_databse_coonection():
try:
host='hostName'
port ='portnumber'
serviceName='sid of you database'
user = 'userName'
password = 'password'
dns = cx_Oracle.makedsn(host,port,service_name=serviceName)
con = cx_Oracle.connect(user, password, dns)
cursor = con.cursor()
query ="select * from table"
cursor.execute(query)
for c in cursor:
print(c)
except cx_Oracle.DatabaseError as e:
print("There is a problem with Oracle", e)
finally:
if cursor:
cursor.close()
if con:
con.close()
get_databse_coonection()
My aim is to connect a MySQL database to a python web scraper I have written.
I have started the process of installing mysql shell, which seems to be the correct version of mysql for my needs. I am following the documentation for downloading X Protocol and am stuck.
Following the instructions to download using MySQL Shell, it says
navigate to the MySQL binaries location (for example, /usr/bin/ on Linux).
Run the following command:
mysqlsh -u user -h localhost --classic --dba enableXProtocol\
Which when I run this command, after being promted to type in my password:
Creating a Classic Session to 'user#localhost'
Enter password:
I then receive this error:
ERROR: 2003 (HY000): Can't connect to MySQL server on 'localhost' (61)
How do I get around this situation?
P.s. I'm not sure if I should be entering 'user' or my actual username 'Frankie'
Error message indicated that you don't have installed MySQL Server.
Firstly, you need to install or upgrade to MySQL 5.7.12 or higher. How to do it is described here https://dev.mysql.com/doc/refman/5.7/en/installing.html
I can login to database in SQL Server Management Studio (SSMS) with the following:
However, in Python I tried
pymssql.connect(host='.\SQLSERVER', user='sa', password='1234', database='HastaneArsiv')
but I got the error message:
pymssql.InterfaceError: Connection to the database failed for an unknown reason.
In the SQL Server Configuration Manager i have verified that TCP/IP is enabled.
What could be the problem ?
There are lots of way can be solve this problem but nothing worked for me.I solved this problem install the Sql Server 2008R2 Service Pack 3 .
I am using pyodbc to query Hive. I also have access to a CLI for entering queries. When I enter the query in CLI, everything runs, but when I enter it in pydobc
cursor.execute(query)
results = cursor.fetchall()
I get this error:
Error: ('HY000', "[HY000] [Cloudera][HiveODBC] (35) Error from Hive: error code: '0' error message: 'java.io.IOException: java.io.EOFException'. (35) (SQLFetch)")
Sometimes it runs fine without giving this error, and sometimes it fails. I am at a loss as to what is causing this. It only happens when I select a subset of columns, not SELECT *.
The message from ODBC shows the "java.io.IOException: java.io.EOFException" which is an exception thrown in a Java stack. The error is very likely not originated from within the ODBC driver but in the server.
The ODBC driver communicates with Hive through the Thrift server (Hive Server 1 or Hive Server 2) but CLI by-passes the Thrift server. Have you try using beeline to reproduce this issue? Beeline uses the open-source JDBC driver to communicate with Hive through the Thrift server.
If this issue is also reproducible with beeline then the error might be originated from the Thrift server while fetching the results. In that case you may want to check the server logs for more details about the error. If you are using CDH you can check the HiveServer2 log in Cloudera Manager (I am guessing you are likely using Hive Server 2).
Cheers,
Holman