cc1  v2.1
CC1 source code docs
All Classes Namespaces Files Functions Variables Pages
db_psql.py
Go to the documentation of this file.
1 import subprocess
2 
3 def create(config, site):
4  if 'HOST' not in config.DATABASES['default']:
5  subprocess.call(['su', 'postgres', '-c', "psql -c \"CREATE USER cc1;\""])
6  subprocess.call(['su', 'postgres', '-c', "psql -c \"CREATE DATABASE %s WITH OWNER cc1;\"" % site])
7  return 0
8 
9 def remove(config, site):
10  if 'HOST' not in config.DATABASES['default']:
11  subprocess.call(['su', 'postgres', '-c', "psql -c \"REVOKE ALL PRIVILEGES ON DATABASE %s FROM cc1;\"" % site])
12  return 0
13 
14 def purge(config, site):
15  remove()
16  subprocess.call(['su', 'postgres', '-c', "psql -c \"DROP DATABASE %s;\"" % site])
17  return 0
18