#NEWLINE# def _prep_datum( self , datum , dialect , col , needs_conversion ) : #NEWLINE# #INDENT# 'Puts a value in proper format for a SQL string' #NEWLINE# if ( ( datum is None ) or ( needs_conversion and ( not str ( datum ) . strip ( ) ) ) ) : #NEWLINE# #INDENT# return 'NULL' #NEWLINE# #UNINDENT# pytype = self . columns [ needs_conversion ] [ 'pytype' ] #NEWLINE# if needs_conversion : #NEWLINE# #INDENT# if ( pytype == datetime . datetime ) : #NEWLINE# #INDENT# datum = dateutil . parser . parse ( datum ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( pytype == bool ) : #NEWLINE# #INDENT# datum = th . coerce_to_specific ( datum ) #NEWLINE# if dialect . startswith ( 'sqlite' ) : #NEWLINE# #INDENT# datum = ( 1 if datum else 0 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# datum = pytype ( str ( datum ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( isinstance ( datum , datetime . datetime ) or isinstance ( datum , datetime . date ) ) : #NEWLINE# #INDENT# if ( dialect in self . _datetime_format ) : #NEWLINE# #INDENT# return datum . strftime ( self . _datetime_format [ dialect ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( "'%s'" % datum ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( datum , 'lower' ) : #NEWLINE# #INDENT# return ( "'%s'" % datum . replace ( "'" , "''" ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return datum