Working Ninja
2015-10-14T10:16:36

\dt - list tables

\l - list databases

\dn - list schemas

\x - toggle extended display

READ MORE

2015-10-14T10:22:24
SELECT count(email),email FROM auth_user GROUP BY email HAVING count(email) > 1;

READ MORE

2016-03-26T10:26:48

GitLab was throwing me a 500 server error this morning after an upgrade via yum. To troubleshoot, I ran the self diagnose command from terminal:

# gitlab-rake gitlab:check

Which gave me the following error to fix:

All migrations up? ... no
  Try fixing it:
  sudo -u git -H bundle exec rake ...

READ MORE

2016-04-06T20:07:45

Today I added a new server to PostgreSQL's host-based authentication file (pg_hba.conf) on a very active PostgreSQL server. Restarting the PostgreSQL service would have lead to service disruption across multiple services. Thankfully the folks at PostgreSQL are one-step ahead of me on this one. There is an option to ...

READ MORE

2016-11-03T20:05:28
import json
import psycopg2
from psycopg2.extras import RealDictCursor

cursor = conn.cursor(cursor_factory=RealDictCursor)
objects = cursor.fetchall()

print json.dumps(objects, indent=2)

# Django
#JsonResponse({'objects': objects})

Source: https://www.peterbe.com/plog/from-postgres-to-json-strings

READ MORE