![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
find-pg-sockets
Advanced tools
Small utility to locate the PostgreSQL unix domain socket file(s) on *nix and bsd hosts.
This utility executes 'netstat -a' and looks for any PostgreSQL server sockets. It is primarily intended to be used by developers that have Postgres running on their local machine and want to connect to their local Postgres server (using node-postgres) over the domain socket, rather than tcp.
This is standalone part of a larger framework I'm working on releasing.
OS X & Linux:
npm install find-pg-sockets --save
Windows:
This is not for Windows.
This example can be found in the 'examples/node-postgres-host' directory in the repo:
'use strict';
/**
~Slightly contrived~ example showing how to use find-pg-sockets
with node-postgres to connect to the local postgres server without
hardcoding the socket file directory, or setting PG_HOST
For this example to work, it must be run as an operating system
user with access to a postgres database with the same
name as the user on the same system over the unix domain socket.
*/
var dirname = require('path').dirname;
var PgClient = require('pg').Client;
var findpgsockets = require('find-pg-sockets');
function connectToPostgres(socketDir) {
console.log('Attempting to connect to postgres using socketDir (' + socketDir + ')');
var client = new PgClient({
host: socketDir
});
client.connect(function(err) {
if (err) {
console.log(err);
} else {
client.query('SELECT current_database() as db', function(err, res) {
if (err) {
console.log(err);
} else {
console.log('Successfully connected to database (' + res.rows[0].db + ')');
}
client.end();
});
}
});
}
findpgsockets(function(err, sockets) {
if (err) {
console.log(err);
} else {
if (sockets.length > 0) {
// pg needs the socket dir to connect that way
var socketDir = dirname(sockets[0]);
connectToPostgres(socketDir);
} else {
console.log('no active socket files found - is postgres running?');
}
}
});
Node >= v6 is required for running tests.
npm test
FAQs
Utility to locate PostgreSQL Unix Domain Sockets
The npm package find-pg-sockets receives a total of 1 weekly downloads. As such, find-pg-sockets popularity was classified as not popular.
We found that find-pg-sockets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.