# # If you're starting with a Python file object f,
# # first do f.flush(), and
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
#
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb') and file_handle.name != os.devnull:
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.close()
#
# #--------------------------------------------
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if type(f_names_list[i]) == file:
# del_name = f_names_list[i].name
# elif type(f_names_list[i]) == str:
# del_name = f_names_list[i]
# else:
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# del_name = None
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
# #--------------------------------------------
#
# # Put patterns outside of sql_txt in order to avoid replacement percent sign
# # with its duplicate ('%' --> '%%') because of Python substitution requirements:
# pattern_01 = '%/#*(=){3,}#"%#"(=){3,}#*/%'
# pattern_02 = '%/#*(#-){3,}#"%#"(#-){3,}#*/%'
#
# sql_txt=''' set bail on;
# set names win1251;
# connect '%(dsn)s' user '%(user_name)s' password '%(user_password)s';
#
#
# -- This is needed to get "cannot transliterate character between character sets"
# -- on build 4.0.0.1631, see comment in the tracker 18/Oct/19 02:57 PM:
# create domain T_A64 as varchar (64) character set WIN1251 collate WIN1251;
# create table VALUT_LIST (NAME T_A64 not null);
# commit;
# insert into VALUT_LIST (NAME) values ('Российский рубль');
# insert into VALUT_LIST (NAME) values ('Турецкая лира');
# insert into VALUT_LIST (NAME) values ('Доллар США');
# commit;
#
# set list on;
# set blob all;
#
# select substring('
# aaa
# /*==== Комментарий между символами "равно" ====*/
# bbb
# ccc
# ddd
# eee
# fff
# jjj
# ' similar '%(pattern_01)s' escape '#') as result1
# from rdb$database;
#
# -- additional check for special character '-' as delimiter:
# select substring('здесь написан /*---- Комментарий между символами "дефис" ----*/ - и больше ничего!' similar '%(pattern_02)s' escape '#') as result2
# from rdb$database;
#
# -- Confirmed fail on 4.0.0.1631 with "cannot transliterate character between character sets":
# select substring(list(T.NAME, '; ') from 1 for 250) as result_3_blob_id from VALUT_LIST T;