change from adodb to php7.2-pgsql - phppgadmin

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

Related

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.

Pyads connection refused with Beckhoff running Twincat 3

I am trying to make a connection from a server running Ubuntu to a Beckhoff PLC with TwinCAT 3. With Windows everything works fine but with the same server on Linux I can't get a connection.
The Linux server has a static IP and in the route manager in the PLC I can find the route and see the server. I have tried adding the route by the route manager in the PLC and with "add_route_to_plc" but both ways my connection is refused. I have already turned off all firewalls. Any of you guys any idea what goes wrong here? In the attachment I have added some picture to see my settings and code that I try to run.
Python error: "connection closed by remote"
Python code:
import pyads
SENDER_AMS = '192.168.1.180.1.1'
PLC_IP = '192.168.1.100'
PLC_USERNAME = 'Administrator'
PLC_PASSWORD = '1'
ROUTE_NAME = 'GID_TEST_ROUTE'
HOSTNAME = 'Grid-stabilizer'
pyads.open_port()
pyads.set_local_address(SENDER_AMS)
pyads.add_route_to_plc(SENDER_AMS, HOSTNAME, PLC_IP, PLC_USERNAME, PLC_PASSWORD, route_name=ROUTE_NAME)
pyads.close_port()
plc=pyads.Connection('192.168.1.100.1.1', pyads.PORT_TC3PLC1)
plc.open()
plc.read_state()
If you are running python on linux and the plc on windows try
plc=pyads.Connection('192.168.1.100.1.1', pyads.PORT_TC3PLC1, PLC_IP)
This will create a route on the linux system. In your code the ip is missing to create a proper route.
Check the port of your plc. It should be 851.

Could not find Host of Azure In App SQL Database

I've created a MySQL In App database for my Azure App, and got the connection string for it. This string is injected into the application.json, and then used to create the actual connection:
WebApplicationBuilder builder = // get it somewhere
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
builder.Services.AddDbContext<DatabaseContext>(options => options.UseMySQL(connectionString));
Only... no connection string works. The one with the port (Database=localdb;Data Source=127.0.0.1:53844;User Id=azure;Password=password) throws:
System.Net.Sockets.SocketException (11001): No such host is known.
And the one without the port (Database=localdb;Data Source=127.0.0.1;User Id=azure;Password=password) throws:
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
This question sugested another connection string (Server=127.0.0.1; Port=53844; Database=localdb; Uid=azure; Pwd=password), which weirdly enough also throws this exception, even though the port is defined:
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
And the manual suggests yet another string (server=localhost;database=localdb;user=azure;password=password) which again throws one of the two exceptions depending on if the port is present.
Connecting via the browser works fine, so I can confirm port, username and password work normally.
Just to be sure, I tried "localhost" as the host, too. Same results.
What am I doing wrong?
It's a mix out of all these connection strings:
server=localhost;port=53844;database=localdb;user=azure;password=password
(Port and server separated, but both present.)
Works for me right now.

Connecting to Aurora Postgres (Babelfish, 1433)

I'm attempting to connect to a new Aurora PostgreSQL instance with Babelfish enabled.
NOTE: I am able to connect to the instance using the pg library through the normal port 5432 (the Postgres TDAS endpoint).
However, for this test, I am attempting to connect through the Babelfish TDS endpoint (1433) using the standard mssql package.
If I specify a database name (it is correct), I receive the error 'database "postgres" does not exist':
var config = {
server: 'xxx.us-east-1.rds.amazonaws.com',
database: 'postgres',
user: 'xxx',
password: 'xxx'
};
and the connection closes since the connection fails.
if I omit the database property in the config, like:
var config = {
server: 'xxx.us-east-1.rds.amazonaws.com',
user: 'xxx',
password: 'xxx'
};
It will connect. Also, I can use that connection to query basic things like SELECT CURRENT_TIMESTAMP and it works!
However, I can't access any tables.
If I run:
SELECT COUNT(1) FROM PERSON
I receive an error 'relation "person" does not exist'.
If I dot-notate it:
SELECT COUNT(1) FROM postgres.dbo."PERSON"
I receive an error "Cross DB query is not supported".
So, I can't connect to the specific database directly and if I connect without specifying a database, I can't cross-query to the table.
Any one done this yet?
Or, if not, any ideas on helping me figure out what to try next? I'm out of ideas.
Babelfish databases (that you connect to on port 1433) have nothing to do with PostgreSQL databases (port 5432). Essentially, all of Babelfish lives within a single PostgreSQL database (parameter babelfishpg_tsql.database_name).
You seem to have a single-db setup, because Cross DB query is not supported. With such a setup, you can only have a single database via port 1433 (apart from master and tempdb). You have to use CREATE DATABASE to create that single database (if it isn't already created; ask sys.databases).
I can't tell if it is supported to create a table in PostgreSQL (port 5432) and use it on port 1433 (the other way around is fine), but if so, you have to create it in a schema that you created with CREATE SCHEMA while connected on port 1433.
The answer was that I should be connecting to database "master".
Even though there is no database titled master in the instance, you still do connect to it.
Once connected, running the following:
select current_database();
This will indicate you are connected to database "babelfish_db".
I don't know how that works or why a database would have an undocumented alias.
The bigger answer here is that cross-DB object references are not currently supported in Babelfish, outside your current SQL Server database.
This is currently being worked on. Stay tuned.

Issue in connecting mongodatabase

I am using mongoose version 4.13.6 and mongodb from compose, and below is my code for connecting to mongo database.
mongoose.createConnection('mongodb://[user]:[pass]#[host1]:[port1],[host2]:[port2]/dbnamme?ssl=true', {});
But when I run this am getting error,
MongoError: no primary found in replicaset
Dont know why is that, can anyone help me in this?
So the short answer is this:
... all drivers are not equal and some make assumptions when multiple hosts are specified. For example, the Meteor/Node.js MongoDB driver sees two hosts and assumes it is talking to a replicaset. Upon connecting the driver asks which host is master and then errors out because neither of them are. The simple fix for this is to use one host in the URI ..
https://www.compose.com/articles/connecting-to-the-new-mongodb-at-compose/#drivingtoyourfirstdatabase
So when you create a connection, simply use one of the connection URIs for the database you want to connect to like:
var uri = "mongodb://<username>:<password>#[host]:[port]/<db_name>?ssl=true";
mongoose.createConnection(uri);

Resources