예제 #1
0
파일: types.py 프로젝트: ngoniboi/pyHANA
 def prepare(cls, value, type_code=type_codes.CHAR):
     pfield = struct.pack('b', type_code)
     if value is None:
         # length indicator
         pfield += struct.pack('B', 255)
     else:
         if not isinstance(value, string_types):
             # Value is provided e.g. as integer, but a string is actually required. Try proper casting into string:
             value = text_type(value)
         value = value.encode('cesu-8')
         length = len(value)
         # length indicator
         if length <= 245:
             pfield += struct.pack('B', length)
         elif length <= 32767:
             pfield += struct.pack('B', 246)
             pfield += struct.pack('H', length)
         else:
             pfield += struct.pack('B', 247)
             pfield += struct.pack('I', length)
         pfield += value
     return pfield
예제 #2
0
파일: types.py 프로젝트: hpi-epic/PyHDB
 def prepare(cls, value, type_code=type_codes.CHAR):
     pfield = struct.pack('b', type_code)
     if value is None:
         # length indicator
         pfield += struct.pack('B', 255)
     else:
         if not isinstance(value, string_types):
             # Value is provided e.g. as integer, but a string is actually required. Try proper casting into string:
             value = text_type(value)
         value = value.encode('cesu-8')
         length = len(value)
         # length indicator
         if length <= 245:
             pfield += struct.pack('B', length)
         elif length <= 32767:
             pfield += struct.pack('B', 246)
             pfield += struct.pack('H', length)
         else:
             pfield += struct.pack('B', 247)
             pfield += struct.pack('I', length)
         pfield += value
     return pfield
예제 #3
0
파일: types.py 프로젝트: ngoniboi/pyHANA
 def to_sql(cls, _):
     return text_type("NULL")
예제 #4
0
파일: types.py 프로젝트: ngoniboi/pyHANA
 def to_sql(cls, value):
     return text_type(value)
예제 #5
0
파일: types.py 프로젝트: hpi-epic/PyHDB
 def to_sql(cls, _):
     return text_type("NULL")
예제 #6
0
파일: types.py 프로젝트: hpi-epic/PyHDB
 def to_sql(cls, value):
     return text_type(value)