Python SQLAlchemy ProgrammingError: Access denied for user 'myuser'#'myhost' - python

I noticed a weird bug when trying to connect to the mysql database (hosted on AWS) using sqlalchemy and Anaconda distribution of Python.
When I connect in the script run by Spyder IDE everything works fine, but when I run the same script (with the same Python env) in IntelliJ IDE, the access is denied.
My user has all required privilleges.
Has anyone experienced a similar issue?

Related

Problem with mysql connector authenticator

I have a problem with a compiled python application. The program runs a GUI with a connection to a MySQL database. At first I was getting the error:
mysql.connector.errors.NotSupportedError: Authentication plugin
'caching_sha2_password' is not supported
The solution I found here, was to add to the connection command:
auth_plugin = 'mysql_native_password'
And my code looked like this:
conn = mysql.connector.connect(host="localhost", user="root", password="Baelca1", auth_plugin='mysql_native_password')
Now when I compile and run it, I get the error:
mysql.connector.errors.NotSupportedError: Authentication plugin
'mysql_native_password' is not supported.
I'm quite frustrated, I've tried several things and none of them work. I uninstalled and reinstalled mysql-connector-python. I changed the mysql-community server settings. Nothing gets the program to work. The application works fine when I run it from the VSCode terminal but not when I convert it to an executable.
If anyone knows how I can fix it, I would be grateful.

jupyter-notebook eith oracle connection problem

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!

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

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.

Why does compiled .exe from python script fail to connect to remote ms access database? [HY024]

I'm attempting to connect to an Access .mdb database with Python pyodbc. I connect to a local database, and this works fine. The database contains linked tables to a back end .mdb on a network drive. I receive this error when attempting to select from the linked table:
pyodbc.Error: ('HY024', "[HY024] [Microsoft] [ODBC Microsoft Access Driver] 'U:\OFFICE\GIS\accessdatabase.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. (-1023) (SQLExecDirectW)")
The path name is correct, and the linked tables work fine if I go into my local database and open them. The python program never mentions the network database or it's path at all, it only connects to the local database.
The python script works fine. I'm only getting the error when running the compiled .exe generated by Pyinstaller. Also, a coworker can compile on Windows 10 and his .exe works fine. But it has to compile on Windows 7 to produce an .exe that works on Windows 7.
Windows 7.
conn_str = (
r'DRIVER={Microsoft Access Driver (*.mdb)};'
r'Uid=Admin;Pwd=;'
r'DBQ=' + self.path
)
Any assistance or pointers would be greatly appreciated! Thanks
Not sure if this is an answer exactly, or more of a work around, but I got it to work by re-linking the remote database tables using '\server\name\path' style paths in the local database, instead of 'U:\path' style ones. Apparently the compiled program was trying to run as administrator for some reason, and in command window the mapped drives were unavailable when running as administrator. Figured I would share in case anyone else has a similar issue.

Categories

Resources