I am trying to connect to the database via Python ?
I use oracle with the sqldevolper and have no problems there, but now when connecting between oracle and python the problem appears.
When I try to connect, I get the following error :
cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
I tried the script with spyder:
import cx_Oracle
con = cx_Oracle.connect(
user="abc",
password ="pass",
dsn="....")
ORA-12514 means you are connecting to a listener, but the service name you specified in your connection string, isn't known by the listener. As you omitted the definition of the connect string (from SQL Developer and Python), hard to say if there is a typo or what caused it...
On the server you can check with "lsnrctl status" on the known services... maybe that gives you a hint, what might be wrong.
Related
I am trying to connect to my Exasol SaaS database, I tried via these tools(TALEND, DBVISUALIZER, POWERBI) and via python but I cannot connect and I keep getting the same error.
I saw another post on Exasol community https://community.exasol.com/t5/discussion-forum/exaconnectionfailederror/m-p/8049#M1855 of this type of error but it doesn't explain exactly what was done to fix the error. I tried via the ODBC Data Source administrator(64-bit) too but still the same error. Maybe its an connection issue with my pc self but I'm not sure or maybe I am just inserting wrong values I don't know.
Oh the values I inserted are the recommended ones from what Exasol docs states and I have removed anything about proxy or vpn.
I put my errors under. I tried via different devices and I get the same error I really don't know what I can do any more, so any help will be greatly appreciated.
Note: I am using the Exasol SaaS database and I am currently on the trial mode so I am not sure if this is limiting me.
**Errors: **
Error message odbc exasol: [EXASOL][EXASolution driver]connection attempt timed out.
Error message Talend : Connection failure. You must change the Database Settings.
java.lang.RuntimeException: com.exasol.jdbc.ConnectFailed: connect timed out ->
Caused by: com.exasol.jdbc.ConnectFailed: connect timed out
Error message pyexasol : socket.timeout: timed out
Error message dbvisualizer : java.net.SocketTimeoutException: Connect timed out com.exasol.jdbc.ConnectFailed: java.net.SocketTimeoutException: Connect timed out
Error message Power BI desktop : Details: "ODBC: ERROR [HYT00][EXASOL][EXASolution driver]Connection attempt timed out."
My applications versions:
DbVisualizer Free 14.0.1 (build: 3540)
Talend Open Studio Data integration(8.0.1.2021119_1610)
java version -> jdk-16.0.02
Power BI -> Version: 2.110.1085.0 64-bit (October 2022)
ODBC : exasolodbc x64 7.1.14
JDBC : exasoljdbc 7.1.14
Python: python 3.8.10 -> pyexasol : 0.25.1
The error means that the client is not able to reach the host for some reason. Try the following:
Make sure the database is still online (they auto-shutdown after 2 hours if there is no activity by default)
Check that the IP Address of the host you are connecting with is added to the allow list in the SaaS UI. (see the docs)
Check if your host is able to reach the host and port specified in the SaaS UI (for example using telnet on port 8563). Maybe some firewall is preventing access to the database?
So I did more digging. actually I have no idea what the issue was.
Talend:
I made a connection via JDBC in Talend with the help of exasol-support. The DBType Exasol in talend doesn't work for some reason, its not known if it's talend side or Exasol side, maybe this will be updated in the future. Just remember in the jdbc url type this: "jdbc:exa:yourconnectionstring", don't forget the "exa".
PowerBI:
I tried the connection string with fingerprint method that worked for me. Just put the fingerprint with the connection string and it should connect.
https://exasol.my.site.com/s/article/PowerBI-Encryption-Fingerprint-Issue-in-Exasol-7-1?language=en_US
DBvisualizer:
I had a wrong in connection string.
Python:
I had a wrong in connection string.
Hopefully this helps someone.
I'd like to pull out data from the Cisco UCCX database (Informix) with a Python script.
After installing the Informix Client SDK and pyodbc as described in this guide, I run the following connection:
pyodbc.connect('SERVICE=1504;PROTOCOL=onsoctcp;CLIENT_LOCALE=en_US.UTF8;DB_LOCALE=en_US.UTF8;DRIVER={IBM INFORMIX ODBC DRIVER (64-bit)};UID=uccxhruser;PWD=my_pwd;DATABASE=db_cra;HOST=my-uccx;SERVER=my-uccx_uccx')
But I get the following error:
Error: ('HY000', '[HY000] [Informix][Informix ODBC
Driver][Informix]INFORMIXSERVER does not match either DBSERVERNAME or
DBSERVERALIASES. (-761) (SQLDriverConnect)')
How can I fix this?
Converting comments into an answer.
On the face of it, you've set the environment variable $INFORMIXSERVER (or specified its value in the connection string) to an incorrect value. Server names should not include dashes, so it might be that SERVER=my-uccx_uccx in the connection string is faulty, or it may be somewhere else. I'd hazard a guess that your server is my_uccx_uccx (an underscore instead of a dash) instead — but that's a guess. Knowing what is specified for the actual server will be crucial.
Does the variable INFORMIXSERVER correspond to the SERVER param in the connection string?
That is information I don't have — there's a decent chance that SERVER in the connection string matches INFORMIXSERVER as an environment variable, but I don't know for sure.
Given the later success, it is probable that SERVER in the connection string corresponds to INFORMIXSERVER in the environment.
Whooooaaaa! Turned out that the server name was my_uccx_uccx instead of my-uccx_uccx and now it works.
Great — I'm glad you're up and running.
I am trying to connect to database using cx_Oracle module i am getting below error
server_IP = ipaddress:1221/xyz
try:
db = cx_Oracle.connect('username', 'password', server_IP)
print db
except cx_Oracle.DatabaseError as e:
error, = e.args
if error.code == 1017:
print('Please check your credentials.')
else:
print('Database connection error: %s'.format(e))
raise
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
My question do i need to install any oracle client in linux or how to configure it in linux so that i won't get this error. please help
What are the preconditions are required in linux to use cx_Oracle module
Please check the syntax of your call to cx_Oracle.connect. It takes username, password and DSN OR one argument that has it all.
For example
con = cx_Oracle.connect('username/password#ipaddress/xyz')
or to construct a full DSN:
ip = 'ipaddress'
port = 1221
SID = 'xyz'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
db = cx_Oracle.connect('username', 'password', dsn_tns)
Using Python With Oracle
To answer the first question: yes, you need to have an Oracle client installed on your machine in order to use cx_Oracle. You can install the full client but it is a lot easier to use the instant client. If you are using an RPM based Linux distribution you can use the RPMs which simplify things considerably. Go here for the instant client:
http://www.oracle.com/technetwork/database/features/instant-client/index.html
The error you are getting suggests a configuration issue, though. Make sure that the Oracle client you use and the version of cx_Oracle you use are compatible with each other. In other words, if Python is 64-bit, your Oracle client should also be 64-bit. If Python is 32-bit, your Oracle client should be 32-bit. Check the environment variables ORACLE_HOME (if using a full Oracle client), PATH and LD_LIBRARY_PATH. This is one of the advantages of using the instant client RPMs -- no environment variables are needed at compile time and none at run-time either!
One last comment: it looks like you are using EZ Connect syntax to connect to the database. The default port for the listener is 1521, not 1221. If you are using the default port you can simply leave out that section (in other words ipaddress/xyz as noted by Martin).
I'm pretty new to python. I'm trying to connect to an informix server using python and ibm_db.connect(). However I can't seem to succeed and the error messages don't help.
Using java and jdbc I can connect successfully with the following connection url:
jdbc:informix-sqli://10.20.30.40:1234/mydb:INFORMIXSERVER=foo_bar;USER=user;PASSWORD=pass;
My attempt at using ibm_db is:
ibm_db.connect('HOSTNAME=10.20.30.40;PORT=1234;DATABASE=mydb;PROTOCOL=ONSOCTCP;UID=user;PASSWORD=pass;', '', '')
But it gives an error (Exception: [IBM][CLI Driver] SQL0902C A system error occurred. Subsequent SQL statements cannot be processed. IBM software support reason code: "". SQLSTATE=58005)
I would like if possible an equivalent string I can put in as the first argument to
ibm_db.connect('', '', '')
So I can connect with python.
Please check https://code.google.com/p/ibm-db/issues/detail?id=116&can=1&q=ONSOCTCP, This might be helpful for you. If you still facing issue then you can post your query to https://groups.google.com/forum/#!forum/ibm_db for quick response.
Protocol onsoctcp is not supported by ibm_db.
Please check https://www.ibm.com/support/knowledgecenter/SSGU8G_11.50.0/com.ibm.admin.doc/ids_admin_0207.htm, This can help you to configure a DDRA (tcpip) access to your database.
I have faced the same issue with ibm_db and now I use jayDeBeApi to connect to Informix through python. it requires java JDBC driver and application is work like a charm.
https://pypi.org/project/JayDeBeApi/#:~:text=The%20JayDeBeApi%20module%20allows%20you,of%20the%20Java%20JDBC%20driver.
Your JDBC connection string points to a SQLI Informix listener, but the 'ibm_db' python module uses DRDA (IBM Data Server Driver) to connect to the Informix engine.
Informix allows both SQLI and DRDA clients (and others like MongoDB). SQLI is the 'native' Informix protocol and supports all the Informix server features and data types. DRDA is what other IBM databases use (like DB2). It does have some limitations in terms of what types you can use.
You have two options:
Configure the Informix server to listen for DRDA connections in a another port (basically, create an DBALIASES using 'drsoctcp') as described here:
https://www.ibm.com/support/knowledgecenter/SSGU8G_11.50.0/com.ibm.admin.doc/ids_admin_0207.htm
Or leave the server as it is, and use a different Python module, one that uses SQLI like 'IfxPy'
https://github.com/OpenInformix/IfxPy
I am using ncclient to connect to the netconf. However when ever i try to connect through python
"ncclient.transport.errors.SessionCloseError: Unexpected session close" error is thrown. the code snippet that i am using is given below
manager.connect('<servername>',22,username='<username>')
Any help on this is much appriciated. I am able to connect to the remote server by using public key, hence i didnt provide passwordk in connect
And in the netconf server logs i am able to see access-denied error. (I got the same prob even when i tried with username and pwd)
You haven't given a lot of information.
Which version of ncclient are you using?
Which version of Python are you using?
Which NETCONF implementation are you trying to connect to? Is this to an actual switch or router, or something like a Linux server running libnetconf or yuma?
Based on the info here, I could imagine a couple of things being wrong:
paramiko isn't using the right key to establish SSH transport.
You're attempting to establish a NETCONF session with an SSH server rather than a NETCONF server.
In your script, create some logs with something like manager.logging.basicConfig(filename='ncclient.log', level=manager.logging.DEBUG) and then re-run your script - do you get anything more informative?
This is an old question, but I hope I can point you in the right direction at least.
its possible that your machines don't know each other (like when you connect via normal ssh and get the "unknown key, really connect (y/n)?" error. In that case, by default the session will not connect. To change this behavior use the "unknown_host_cb" parameter:
def allowUnknownHosts(host,fingerprint):
return True
self.manager = manager.connect(host=host, port=port, username=user,password=password, unknown_host_cb=allowUnknownHosts)