jupyter-notebook eith oracle connection problem - python

I have a problem that I've been trying to solve for a very long time and it seems like I'm missing something very basic.
I use a Linux server with Anaconda, Oracle client, Pycharm and jupyter-notebook installed.
I use python scripts in which I write and read data to Oracle DB, and I use the Cx_oracle extension.
The server has several users with a personal username for each and each of them has sudo privileges.
I performed all the installations on the server with sudo privileges.
When I try to connect from the server to Oracle DB I connect properly.
When I connect to Python on the server itself, I connect properly to Oracle DB.
When I connect using Pycharm and I define ORACLE_HOME=/OracleTools/19.0.0/ in the environment variables, I connect properly to the Oracle DB.
My problem starts when I want to use jupyter-notebook
When I try to connect to the DB I get the error -
DatabaseError: Error while trying to retrieve text for error ORA-12715
I noticed when I execute os.environ I see that it is defined for me:
ORACLE_HOME: /OracleTools/19.0.0/bin
and should be
/OracleTools/19.0.0
So I changed using command os.environ['ORACLE_HOME'] = '/OracleTools/19.0.0'
Then I get an error:
DatabaseError: ORA-12715: invalid character set specified
And of course this change is not permanently saved ...
If on the server itself I execute the env command both in the private user and in sudo I see ORACLE_HOME: /OracleTools/19.0.0 and not ORACLE_HOME: /OracleTools/19.0.0/bin
My questions:
Where does the data I get in the os.environ command come from?
How can I edit them permanently ?
Is this even the problem I'm having or should I check something else?
I manage to import cx_oracle, which means that there is no problem of expansion
Thanks!

Related

DB Connect failure python cx_Oracle - ORA-01804

I try to connect oracle DB with cx_Oracle package in python 3.9.7.
cx_Oracle version is 8.3.0.
when i try to connect with command cx_Oracle.clientversion() i got error :
DatabaseError: Error while trying to retrieve text for error ORA-01804
Linux Os , attach my .bash_profile
with sqlplus command i success to connect the DB.
.bash_profile :
Thanks
This error generally occurs when there is a discrepancy between the value of the environment variable ORACLE_HOME and the actual library that was loaded. You can set the environment variable DPI_DEBUG_LEVEL to the value 64 and run your script. It will tell you which method was used to load the library. If that doesn't help you figure it out, paste the output in your question and I'll try to help further.
Note as well that there is a new driver available (python-oracledb) which doesn't require Oracle Client libraries and therefore shouldn't run into this issue. Take a look here: https://levelup.gitconnected.com/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a

Problems connecting to postgre with python (in pg_hba.conf)

I am trying to connect to a Postgres database from a Jupyter Notebook using the psycopg2 library.
First of all, I installed it:
conda install psycopg2
Looks fine. Next step was try to connect to by database in cloud:
import psycopg2
conn = psycopg2.connect(#my_database_credentials)
And I got error like:
FATAL: no pg_hba.conf entry for host...
I am starting to find this file, and found two on my computer. One in /UserName/Anaconda3/Library/share and one in /UserName/Anaconda3/libpq-11.2-h3235a2c_0/Library/Share
So, I changed both files in several different ways, for example:
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all all trust
But I still got the same error. So my question is:
What else do I need to install? Or maybe I need to configure other files? Or what I need to do to connect to the database. Thank you

Can't Connect Python Flask With PSQL Database

every time i try to make connection between python and PSQL this error disappear ?
You need to first make sure your DATABASE_URL has been defined before you even run your server. If you are using an online database and have a url, executing the command in terminal (for mac/linux):
export DATABASE_URL = "https://my_database_link"
inside your virtual environment, where you installed python will connect your virtual environment variable to your database online. If you are still experiencing problems. make sure you have installed everything correctly.

How to get Python clear-text plugin auth working on Windows (using MySQLdb)?

I have a MariaDB 5.5.57-1ubuntu0.14.04.1 installed on Ubuntu Linux 14.04 and configured with the following to authenticate MySQL users using our OpenLDAP infrastructure via PAM:
# cat /etc/mysql/conf.d/ldap.cnf
[mysqld]
pam-use-cleartext-plugin
plugin-load = auth_pam.so
# cat /etc/mysql/conf.d/ssl.cnf
[mysqld]
ssl-cipher = DHE-RSA-AES256-SHA
ssl-ca=/etc/mysql/ssl/ca-cert.pem
ssl-cert=/etc/mysql/ssl/server-cert.pem
ssl-key=/etc/mysql/ssl/server-key.pem
I've created my user in mysql like this:
MariaDB [(none)]> CREATE user 'ldap1'#'%' IDENTIFIED VIA pam;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test.* TO 'ldap1'#'%' IDENTIFIED VIA pam REQUIRE SSL;
I can authenticate from a remote Linux host doing this:
mysql -u ldap1 -p -h my.server.net --ssl --enable-cleartext-plugin
When I connect from MySQL Workbench on Windows 7 I can tick 'Enable Cleartext Authentication Plugin' under the Advanced tab (Require SSL of course) and authenticate as well there too.
When I run my Python script, I get the error message below. Anyone know a fix or is there a DLL I need to install?
NOTE:The code I'm using was sent to me from an outside developer and not so sure I can share the code so just posting the error output. If this is not a common problem with a known workaround (It's been difficult finding all the right pieces to do this from both Linux and Windows platforms) I can certainly email said developer and ask about posting watered down version of the connect routine. The code does import MySQLdb to establish the DB connection if it matters.

Installing X Protocol in order to use mysql shell - Mac

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

Categories

Resources