<commit_before>from datetime import datetime

import fabric.api

from fab_deploy.package import package_install

def _postgresql_is_installed():
	with fabric.api.settings(fabric.api.hide('stderr'), warn_only=True):
		output = fabric.api.run('postgresql --version')
	return output.succeeded

def postgresql_install():
	""" Installs postgreSQL """
	if _postgresql_is_installed():
		fabric.api.warn(fabric.colors.yellow('PostgreSQL is already installed.'))
		return

	package_install(['postgresql-client-common','postgresql-common'])

def postgresql_execute(sql, user='', password=''):
	"""
	Executes passed sql command using postgresql shell.
	"""
	return fabric.api.run("echo '%s' | psql -u%s -p%s" % (sql, user, password))

def postgresql_create_db():
	"""
	Create an empty postgresql database.
	"""
	pass

def postgresql_create_user():
	"""
	Creates a new postgresql user.
	"""
	user     = fabric.api.runprompt('Please enter username:')
	new_user = fabric.api.runprompt('Please enter new username:')
	
	fabric.api.run("createuser %s -P -U %s" % (new_user, user))

def postgresql_drop_user():
	""" Drop a postgresql user """
	pass

def postgresql_dump():
	""" Runs postgresqldump. Result is stored at /srv/active/sql/ """
	dir = '/srv/active/sql/'
	pass

def postgresql_load():
	""" Load a postgresql database """
	pass

def postgresql_backup():
	""" Backup the database """
	pass<commit_msg>Updated postgresql create db.<commit_after>from datetime import datetime

import fabric.api

from fab_deploy.package import package_install

def _postgresql_is_installed():
	with fabric.api.settings(fabric.api.hide('stderr'), warn_only=True):
		output = fabric.api.run('postgresql --version')
	return output.succeeded

def postgresql_install():
	""" Installs postgreSQL """
	if _postgresql_is_installed():
		fabric.api.warn(fabric.colors.yellow('PostgreSQL is already installed.'))
		return

	package_install(['postgresql-client-common','postgresql-common'])

def postgresql_execute(sql, user='', password=''):
	"""
	Executes passed sql command using postgresql shell.
	"""
	return fabric.api.run("echo '%s' | psql -u%s -p%s" % (sql, user, password))

def postgresql_create_db():
	"""
	Create an empty postgresql database.
	"""
	database = fabric.api.runprompt('Please enter database name:')
	
	fabric.api.run("createdb %s" % (database))

def postgresql_create_user():
	"""
	Creates a new postgresql user.
	"""
	user     = fabric.api.runprompt('Please enter username:')
	new_user = fabric.api.runprompt('Please enter new username:')
	
	fabric.api.run("createuser %s -P -U %s" % (new_user, user))

def postgresql_drop_user():
	""" Drop a postgresql user """
	pass

def postgresql_dump():
	""" Runs postgresqldump. Result is stored at /srv/active/sql/ """
	dir = '/srv/active/sql/'
	pass

def postgresql_load():
	""" Load a postgresql database """
	pass

def postgresql_backup():
	""" Backup the database """
	pass
{'fraction_non_alphanumeric': 0.14497245179063362, 'fraction_numerical': 0.0, 'mean_word_length': 4.989690721649485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3279557', 'n_tokens_mistral': 1011, 'n_tokens_neox': 970, 'n_words': 239}