#NEWLINE# def load_sql( self , filename = None , data = None ) : #NEWLINE# #INDENT# cmdline = [ self . find_psql ( ) ] #NEWLINE# cmdline . extend ( self . get_psql_options ( ) ) #NEWLINE# if ( not data ) : #NEWLINE# #INDENT# logger . debug ( 'loading sql from %s' , filename ) #NEWLINE# with open ( filename , 'r' ) as fin : #NEWLINE# #INDENT# p = self . popen ( cmdline , stdin = fin ) #NEWLINE# p . communicate ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( data ) > 105 ) : #NEWLINE# #INDENT# tdata = ( data [ : 100 ] + '...' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tdata = data #NEWLINE# #UNINDENT# logger . debug ( 'running sql command: "%s"' , tdata ) #NEWLINE# p = self . popen ( cmdline , stdin = PIPE ) #NEWLINE# if isinstance ( data , unicode ) : #NEWLINE# #INDENT# data = data . encode ( ) #NEWLINE# #UNINDENT# p . communicate ( data ) #NEWLINE# #UNINDENT# if p . returncode : #NEWLINE# #INDENT# raise PgxnClientException ( ( 'psql returned %s loading extension' % p . returncode ) )