SQLanywhere & SqllanyDB Specified database not found', -83 - python-3.x

I'm trying to connect to a SAP SQLANYWHERE server using syqlanydb library and even sqlalchemy however both scenarios I get
sqlanydb.OperationalError: (b'Specified database not found', -83)
I can use the same connection details to connect using clients such as DBeaver but no matter what can't connect to this server, I've also tried ODBC drivers but server wasn't returning anything.
I have sqlanywhere 17 installed matching server and port 2638 is open. Have in mind this is a remote server.
My connection string:
sybase_connection_string = "sqlalchemy_sqlany://{user}:{pwd}#{host}:{port}/{db}".format(user=user, pwd=pwd, host=host, port=port, db=database)
engine = create_engine(sybase_connection_string)
engine.connect(sybase_connection_string)
Has anyone experienced this?
Thanks

Related

Python: Error while connecting to SQL Server (ODBC 17)

Getting below error while executing SQL statement using pd.read_sql()
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08001',
'[08001] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL
Provider: [error:0A0C0103:SSL routines::internal error] (-1)
(SQLDriverConnect)')
Python version 3.10.8. Other packages:
pyodbc==4.0.35
pandas==1.5.2
pymysql==1.0.2
sqlalchemy==1.4.46
I want to execute the above command successfully.
The error message 'ODBC 17' distinctively specifies a failure in establishing a connection to a SQL Server database through ODBC driver. This can be caused by;
Incorrect connection details such as server name, database name, username, and password.
ODBC driver not installed or not properly configured on the machine.
In order to solve this, try and verify the connection details and ensure they are correct or Install or reinstall the ODBC driver and make sure it's properly configured.
If the above doesn't work, kindly check the firewall settings and ensure that the connection is not being blocked.
Hope this helps.

How to create the connection string for a database generated with pgAdmin4

I developed my app with SQLAlchemy testing it on an SQLite database.
Now I would like to testing more using PostgreSQL but in a localhost once again.
For this reason, I tried to create a local Postgre database with pdAdmin4 (my laptop has Windows 7 so I installed the v4 version of the database manager).
Now I am trying to generate the connection string for this Postgre database but I cannot understand how to do it.
This is what I created in pgAdmin4:
while the details of the server are these:
The connection string I am trying to use is this:
selected_engine = create_engine('postgresql+psycopg2://postgres:123#localhost/test_server/test_database')
The password 123 is the password I set at the first access to pgdAmin4.
However, I got this error:
OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: FATAL: database "test_server/test_database" does not exist
I am sure I am wrong and I cannot figure out what is the correct URL for my database.

Trying to connect from DataStax Studio to my Astra cluster - Connection test failed

Just got my brand new 6.8 DataStax Astra (Cassandra) and downloaded studio from https://www.datastax.com/dev/datastax-studio. My Nodejs connection works great. But trying connect from Studio - everything fails with SSL configurations:
All host(s) tried for query failed.. (com.datastax.driver.core.exceptions.TransportException:
It looks like port should be 29080 as per secure-connect .. /config.json
I used API User Admin Token for Client and Secret keys.
Not sure if it's related but python connection fails with:
...cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers'
...Unauthorized('Error from server: code=2100 [Unauthorized] message="No SELECT permission on <table system_virtual_schema.keyspaces>"')
It can't connect to Astra because it's connecting to the wrong CQL port.
The correct port configuration is in the cqlshrc file in the [connection] section. For example:
[connection]
hostname = db-uuid-us-east1.db.astra.datastax.com
port = 39876
ssl = true
This is the correct CQL port to use to connect from Studio or other clients. Cheers!
Cassandra 6.8 Astra is currently using port 29042 by default.
Both Python connector and Studio work great under Admin User credentials, but not under the Admin API User. So the authorization error message was ligid. NodeJS works great with Admin API User credentials..

Connecting to Azure PostgreSQL server from python psycopg2 client

I have trouble connecting to the Azure postgres database from python. I am following the guide here - https://learn.microsoft.com/cs-cz/azure/postgresql/connect-python
I have basically the same code for setting up the connection.
But the psycopg2 and SQLalchemy throw me the same error:
OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I am able to connect to the instance by other client tools like dbeaver but from python it does not work.
When I investigate in Postgres logs I can see that the server actually authorized the connection but the next line says
could not receive data from client: An existing connection was forcibly closed by the remote host.
Python is 3.7
psycopg's version is 2.8.5
Azure Postgres region is in West Europe
Does someone has any suggestion on what should I try to make it work?
Thank you!
EDIT:
The issue resolved itself. I tried the same setup a few days later and it started working. Might have been something wrong with the Azure West Europe.
I had this issue too. I think I read somewhere (I forget where) that Azure has an issue with the # you have to for the username (user#serverName).
I created variables and an f-string and then it worked OK.
import sqlalchemy
username = 'user#server_name'
password = 'PassWord!'
host = 'server_name.postgres.database.azure.com'
database = 'your_database'
conn_str = f'postgresql+psycopg2://{username}:{password}#{host}/{database}'
After that:
engine = sqlalchemy.create_engine(conn_str, pool_pre_ping=True)
conn = engine.connect()
Test it with a simple SQL statement.
sql = 'SELECT * FROM public.some_table;'
results = conn.engine.execute(sql)
This was a connection in UK South. Before that it did complain about the format of the username having to use #, although the username was correct, as tested from the command line with PSQL and another SQL client.

change from adodb to php7.2-pgsql

Change phppgadmin connection from adodb to php7.2-pgsql
Tried running an SQL query on database from phppgadmin and got error "Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /usr/share/php/adodb/adodb-error.inc.php on line 114"
In my config.inc.php I don't see anything about defining a connection type
// Display name for the server on the login screen
$conf['servers'][0]['desc'] = 'PostgreSQL';
// Hostname or IP address for server. Use '' for UNIX domain socket.
// use 'localhost' for TCP/IP connection on this computer
$conf['servers'][0]['host'] = 'phppgadmin.com';
// Database port on server (5432 is the PostgreSQL default)
$conf['servers'][0]['port'] = 5432;
I would like to change the default connection from adodb to php7.2-pgsql
You need to run a newer version of phppgadmin with proper support for php7. I'd suggest just grabbing the code from git master at https://github.com/phppgadmin/phppgadmin

Resources