<commit_before># The Admin4 Project
# (c) 2013-2014 <NAME>
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage


import adm
from wh import xlt, YesNo
from _pgsql import pgConnectionPool, pgQuery, pgTypeCache, psycopg2, quoteIdent, quoteValue

adminProcs=['pg_terminate_backend', 'pg_rotate_logfile', 'pg_reload_conf']

class Server(adm.ServerNode):
  shortname=xlt("pgsql Server")
  typename=xlt("PostgreSQL Server")
  
#  wantIconUpdate=True

  def __init__(self, settings):
    adm.ServerNode.__init__(self, settings)
    self.maintDb=settings['maintdb']
    self.version=None
    self.connectableDbs=None
    self.typeCache=None
#    self.timeout=settings.get('querytimeout', standardTimeout)

      
  def GetConnection(self):
    if not self.connection:
      return None
    self.CheckConnection(self.connection)
    return self.connection

  def GetCursor(self):
    conn=self.GetConnection()
    if conn:
      return conn.GetCursor()
    return None
  
  
  def IsConnected(self, _deep=False):
    return self.connection != None

  def GetDsn(self, dbname, application):
    params= [('host', self.address),
            ('port', self.port),
            ('dbname', dbname),
            ('user', self.user),
            ('password', <PASSWORD>),
            ('connect_timeout', 3),
            ('application_name', application)
            ]
    return ' '.join(["%s=%s" % (key, psycopg2._param_escape(str(val))) for (key, val) in params])
    

  def GetType(self, oid):
    if self.version < 8.4:    category="' '::char as typcategory"
    else:                     category="typcategory"
    sql="""<commit_msg>unicode escaped dsn<commit_after># The Admin4 Project
# (c) 2013-2014 <NAME>
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage


import adm
from wh import xlt, YesNo
from _pgsql import pgConnectionPool, pgQuery, pgTypeCache, psycopg2, quoteIdent, quoteValue

adminProcs=['pg_terminate_backend', 'pg_rotate_logfile', 'pg_reload_conf']

class Server(adm.ServerNode):
  shortname=xlt("pgsql Server")
  typename=xlt("PostgreSQL Server")
  
#  wantIconUpdate=True

  def __init__(self, settings):
    adm.ServerNode.__init__(self, settings)
    self.maintDb=settings['maintdb']
    self.version=None
    self.connectableDbs=None
    self.typeCache=None
#    self.timeout=settings.get('querytimeout', standardTimeout)

      
  def GetConnection(self):
    if not self.connection:
      return None
    self.CheckConnection(self.connection)
    return self.connection

  def GetCursor(self):
    conn=self.GetConnection()
    if conn:
      return conn.GetCursor()
    return None
  
  
  def IsConnected(self, _deep=False):
    return self.connection != None

  def GetDsn(self, dbname, application):
    params= [('host', self.address),
            ('port', self.port),
            ('dbname', dbname),
            ('user', self.user),
            ('password', <PASSWORD>),
            ('connect_timeout', 3),
            ('application_name', application)
            ]
    return ' '.join(["%s=%s" % (key, psycopg2._param_escape(unicode(val))) for (key, val) in params])
    

  def GetType(self, oid):
    if self.version < 8.4:    category="' '::char as typcategory"
    else:                     category="typcategory"
    sql="""
{'fraction_non_alphanumeric': 0.12560386473429952, 'fraction_numerical': 0.008454106280193236, 'mean_word_length': 3.188369152970923, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '7171557', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1027, 'n_words': 243}