I'm trying to connect to a database using ibm_db api with python but its throwing this error:
SystemError: returned NULL without setting
an error
I've used the same exact script on another machine and it works fine. So it seems like some issue with this machine. I'm using python 3.7 on this machine and python 3.6 on the other one.
Here is the code:
from ibm_db import connect
connection = connect('DATABASE=DB2test;'
'HOSTNAME=localhost;'
'PORT=50000;'
'PROTOCOL=TCPIP;'
'UID=etl;'
'PWD=123!#123ETLLET;', '', '')
By the way, I'm able to connect the same database using DBeaver.
Related
I'm trying to run my python code on AWS Lambda to send data to my postgres DB on Heroku. The code works totally fine in my local, but when I test it on AWS, I keep getting this error message:
[ERROR] OperationalError: sslmode value "require" invalid when SSL support is not compiled in
FYI, I'm running this on python 3.8 with psycopg2, enabling the sslmode=require when connecting postgres via psycopg2.
Has anyone encountered a similar issue?
I'm using an AWS Lambda function (in Python) to connect to an Oracle database (RDS) using cx_Oracle library. But it is giving me the below error - "DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory".
Steps I've followed -
Created a python virtual environment and downloaded the cx_Oracle library on an EC2 instance.
Uploaded the downloaded library on S3 bucket and created a Lambda Layer with it
Used this layer in the Lambda function to connect to the Oracle RDS
Used below command to connect to the DB -
conn = cx_Oracle.connect(user="user-name", password="password", dsn="DB-Endpoint:1521/"database-name",encoding="UTF-8")
Please help me in resolving this issue.
Set the environment variable DPI_DEBUG_LEVEL to the value 64 and then rerun your code. The debugging output should help you figure out what is being searched. Note that you need to have the 64-bit instant client installed as well!
The reason I faced this issue was that I just downloaded cx_Oracle library. In order to connect to the Oracle database from the Lambda function, we need to download the Oracle client and libaio libraries as well and club them with cx_Oracle to create a Lambda Layer. Once I followed these steps, I was able to connect to the Oracle database and query its tables. I've created a video for this process, so that others need not go through the issues I faced. Hope it will be helpful to all - https://youtu.be/BYiueNog-TI
I've been trying to connect to a MySQL database remotely but I keep getting the error:
2055: Lost connection to MySQL server at 'local.mysql.database.azure.com:3306', system error: 1 [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1045)
Using the exact same connection details I am able to connect to the database through MySQL Workbench and through Node. For some reason the connection won't go through in python.
This user's as not created to require SSL.
I've been trying to figure out the problem but I'm drawing blanks.
Below is my python login block.
config = {
'host':'local.mysql.database.azure.com',
'user':'user#local',
'password':'password',
'database':'random_db'
}
I've been able to connect to a MySQL instance on the Google Cloud Platform with the exact same connection block but it doesn't work for the Azure connection. I've looked for differences between the two platforms which could have caused this and the only thing I could find was that the Azure MySQL version was 5.7.32log while the GCP was 8.0.18.
I am also currently running python 3.7.0, not sure if that changes anything.
Is there another module I could use if that is the problem, or do I need to downgrade something? I have no idea.
According to this 5.7.29 is the latest 5.7 supported so 5.7.32 would give wrong version error.
I am connecting to an Oracle DB using LDAP and the Python cx_Oracle library. I have proper sqlnet.ora, ldap.ora and tnsnames.ora files. On my Windows machine everything works fine using the 12.1 Oracle client and the following Python code:
import cx_Oracle
connection = cx_Oracle.connect(user/password#db, mode=cx_Oracle.SYSDBA)
I have installed the Oracle instant client 12.1 on my Linux machine (Debian) following the zip file installation method advised on the Oracle website (at the bottom of https://www.oracle.com/be/database/technologies/instant-client/linux-x86-64-downloads.html).
ldconfig correctly lists the oracle client libraries and their paths.
I copy the exact same sqlnet.ora, ldap.ora and tnsnames.ora files from my Windows machine to my Linux machine
in /opt/oracle/instantclient_12_1/network/admin, as advised by the cx_Oracle documentation.
Now running the above Python code on my Linux machine I have the following error:
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified
I tried as well setting the environment variable TNS_ADMIN=/opt/oracle/instantclient_12_1/network/admin and ORACLE_HOME=/opt/oracle/instantclient_12_1/ with no success neither
Could any of you help me debugging this and understand why the client config on my Linux machine does not work?
Installed the latest 19 client and everything works as expected.
I am trying to connect from python code to mysql configured with replica set to enable high availability.
So far I tried it using SqlAlchemy but not able to have multiple instances for mysql.
Python version : 3.6
Mysql verision : 4.1.4
The connection string which I am using so far :
MYSQL_CONNECTION_STRING=mysql+mysqlconnector://%%s:%%s#localhost:3306/my_database
In normal scenario is it getting connected and working fine but through HA configuration its not getting connected.