Skip to content

Instantly share code, notes, and snippets.

View sriramsreedhar's full-sized avatar
🏠
Working from home

Sriram Sreedhar sriramsreedhar

🏠
Working from home
View GitHub Profile
@sriramsreedhar
sriramsreedhar / django_create_user.gist
Created November 3, 2020 06:48 — forked from makeittotop/django_create_user.gist
Create / remove user / superuser in a django app
>>> from django.contrib.auth.models import User
# Create a regular user 'foo'
>>> user = User.objects.create_user('foo', '[email protected]', 'bar')
# List all users
>>> User.objects.all()
[<User: admin>, <User: abegail>, <User: foo>]
>>> User.objects.all()[1].is_superuser
@sriramsreedhar
sriramsreedhar / postgres-cheatsheet.md
Created September 28, 2020 00:13 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)