Skip to content

Instantly share code, notes, and snippets.

@r-m-n
r-m-n / gist:8ebda5f8db376635dd66
Created July 9, 2015 13:36
sqlalchemy comparator.py
class Cidr(postgresql.CIDR):
'''
Делаем свой тип колонки для того, чтобы была возможность использовать
операторы >> и <<
'''
class comparator_factory(postgresql.CIDR.Comparator):
def __lshift__(self, other):
return self.op("<<")(other)
def __rshift__(self, other):
return self.op(">>")(other)
@r-m-n
r-m-n / pg_all_indexes.sql
Created June 11, 2013 10:30
postgres get all indexes
SELECT
n.nspname AS "schema",
c.relname AS "index"
FROM
pg_catalog.pg_class AS c
LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
WHERE
c.relkind = 'i'
AND
n.nspname NOT IN ('pg_catalog', 'pg_toast')