我试图遵循pyorient的github自述文件中给出的示例。我尝试使用client.record_create
插入二进制字段,并使用client.record_load
加载相同的字段。
>>> client.db_create('animals', pyorient.DB_TYPE_DOCUMENT, pyorient.STORAGE_TYPE_MEMORY )
>>> cluster_id = client.command("create class animal")
>>> rec = { '@animal': { 'accommodation': 'house1', 'work': 'office1', 'holiday': b'\xb8P\xa7\x00l|\xa7\x13\x8d\xc8\x80_M\xa0\x11V\xe3 ,G\x1d\xad \x08\xf5rZ\xafc\x16\x1c(' } }
>>> rec_position = client.record_create( cluster_id[0], rec )
>>> loaded = client.record_load(rec_position._rid)
>>> loaded.oRecordData
{'holiday': None, 'work': 'office1', 'accommodation': 'house1'}
如您所见,检索到的二进制字段的值为None。 pyorient是否支持插入原始字节?如果没有,是否有一些解决方法?
答案 0 :(得分:0)
不确定结果是否正确,但您可以尝试添加“”
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int TAM_BUFFER = 75;
int main(int argc, char *argv[]){
char fileoutputname[15] = {0};
char buffer[TAM_BUFFER];
FILE *arquivo = fopen("Entrada.txt", "r");
FILE *saida;
if(arquivo == NULL){
perror("fopen");
exit(EXIT_FAILURE);
}
fscanf(arquivo, "%14c", fileoutputname);//first split file name
saida = fopen(fileoutputname, "w");
rewind(arquivo);
while(fgets(buffer, sizeof buffer, arquivo)){
if(strncmp(buffer,"NEWDAY", 6) == 0){ // strlen("NEWDAY") is 6
long file_pos = ftell(arquivo);//or use fgetpos for large file, save file position
fscanf(arquivo, "%14c", fileoutputname);//next file name
fseek(arquivo, file_pos, SEEK_SET);//or use fsetpos (pair with fgetpos), restore file position
saida = freopen(fileoutputname, "w", saida);//fclose(saida);saida=fopen(fileoutputname, "w");
}
fprintf(saida,"%s", buffer);//No add newline
}
fclose(arquivo);
fclose(saida);
return 0;
}