Connecting ElasticSearch to Superset - python

I need to connect ElasticSearch to Superset for visualization. When I checked in Superset in Sources> Databases, it mentioned to use SQLAlchemy URI and Database for testing the connection.
In our case, ElasticSearch is connected with Python library and not using SQLAlchemy.
Is there any way to connect Elastic Search with Superset using Python library and if so could you please help by mentioning the way to connect?

you can connect by the way mentioned in the docs.You need to add the dbapi python package mentioned in superset installer document and that will in turn help you connect to the elk using the url elasticsearch+http://{user}:{password}#{host}:9200/
pip install elasticsearch-dbapi

Related

How do I connect to Oracle Exadata from Python?

I have tried connecting exadata from python using cx_Oracle, but faced issue stating
cx_Oracle.DatabaseError: DPI - 1047: Cannot locate a 64bit Oracle client library.
I am trying to install a 64bit cx_Oracle, but I need to know can I connect from python to exadata.
Follow the cx_Oracle Linux installation instructions. The piece you are missing is access to Oracle Client libraries. As noted in the other answer, using Instant Client is the way to go. You'll need the "Basic" or "Basic Light" package for Linux x86-64. If you don't know your character set requirement, then use "Basic". You can use the latest 19c version. This will let you connect to Oracle DB 11.2 and newer.
If you have root access (?) you may find the RPM packages easier. If you want to use ZIP files, unzip the package, set your LD_LIBRARY_PATH environment variable to the directory, and run Python.
In your cx_Oracle scripts you use the same database credentials and connection string that you would use in SQL*Plus.
Welcome to Stack Overflow!
For the record, Oracle Exadata is a platform consisting of hardware and software designed for extreme Oracle Database performance. cx_Oracle is the Python client library to operate on an Oracle Database - hence you want to connect to an Oracle Database utilizing the Python programming language.
cx_Oracle depends on OCI (Oracle Call Interface). You need to download and install Oracle Client Library on your workstation before you can do import cx_Oracle from within Python.
You will find the Oracle Client Library here
Best of luck!

Can Python directly read in a Hive table?

Is there a module or a connector that allows Python directly access Hive tables? Any help would be greatly appreciated.
Python has a Pyhive library that you can use to connect to hive database and run query against them.
it allows you to connect through JDBC and Kerberos Authentication. However, it's bit buggy and JDBC over SSL seems not supported.
This is how you connect
connection = hive.connect(host='HIVE_HOST',
port=10000,
database='temp',
username='HIVE_USERNAME',
password='HIVE_PASSWORD',
auth='CUSTOM')
You can find more details here.
http://allabouthadoop.net/how-to-access-hive-with-python-script/
And these are the two issues I am talking about
https://github.com/dropbox/PyHive/issues/258
https://github.com/dropbox/PyHive/issues/257

Read/Write Mysql DB using Python API

Is there any Python API that will allow me to interact with a remote MySQL db (running on RDS) in a transactional manner (read, write)? I believe this can be done using Boto for DynamoDB but I couldn't find anything similar for MySQL.
Any suggestions?
Thanks,
Bucho
There is no such thing in Boto,
The easiest and simplest library to interact with MySQL using python in my opinion is MySQLdb.

How do I access an Oracle db without installing Oracle's client and cx_Oracle?

I have two RHEL servers running Python 2.4 and 2.6 separately. There is an Oracle database on the other server I need to access.
I was trying to install cx_oracle on my RHEL server but found out that the Oracle client must be installed first.
The problem is, I don’t have permission to install Oracle's client on both RHEL servers. On the same servers, a Perl program can connect to the Oracle db using:
DBI->connect("dbi:Oracle:host=myhost.prod.com;sid=prddb",'username','password')
Can Python do the same without installing cx_oracle and the Oracle client? Or are there any suggestions about how to write a module myself to do the same thing?
Thanks in advance!
An excerpt from https://forum.omz-software.com/topic/184/oracle-database:
There's no pure python client for Oracle and likely never will be. Even wonderful third-party toolsets like SQLalchemy still rely on cx_Oracle underneath to do the actual communication to the Oracle database servers.
—also, deciding by Google, the answer is no: there do not seem to be any pure Python Oracle clients in existence as of today.
Usually, all you need are the libraries, which don't necessarily require sudo rights. Extract them to a place the software will be able to read from and set the following environment variables accordingly:
ORACLE_HOME=path/to/where/you/extracted/libs
TNS_ADMIN=path/to/tnsnames.ora
I have had best luck skipping tnsnames, and just specifying the host, port, etc in the connection, but it's quite possible you'll need it for cx_oracle...I don't remember from when I used it ages ago.
if you don't want use cx_Oracle you should use expect scripting. ( for python pexpect). But you need to be carefully for handle all expectations.

Best way to access Firebird DB from a remote desktop.

I have a Firebird DB set up on my computer and I want to be able to retrieve data from a different computer. What is the best way to go about this?
I am running windows and using python.
Install firebird client to the client pc
To connect firebird programmaticaly from python you should install a python Firebird driver.
For Python 2.x, you can use kinterbasdb. This is the legacy driver and I think it is not actively developed but only maintained.
To connect windows based server database from kinterbasdb you can use
Import kinterbasdb as k
k.init(type_conv = 300) #
con = k.connect(dsn='127.0.0.1:c:\\db\\test.fdb', user='sysdba', password='masterkey', charset='YOUR_CHARSET', dialect=3)
Of course you should adjust connection parameters according to your system. Kinterbasdb documentation is here
If you want use an ORM, you can use SqlAlchemy which uses kinterbasdb for Firebird Support
For Python 3k you can use pyfirebirdsql which also supports Python 2.5+ and under active development, but not supported by SqlAlchemy yet.
Run Firebird server on the computer with database file and connect to it from remote computer. You will need in Firebird client library installed on remote computer.
I think we need a bit more info.
Do you want database access - as in "I want to be able to edit table layout and define new tables, views, procedures and so on" ?
Or do you only need to get data from the database using python ?
The latter could be achieved by installing a Firebird client (in essence its a dll (fbclient.dll)) and then use a connect string from python to connect to your database.

Categories