Re: Problem using shared D library from C shared library
On 07/04/2016 5:23 PM, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 04:36:02 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote: [...] Looks like _d_arrayappendcTX asked for a enormous amount of memory and it fails, can't figure out why Just find out it's my own fault. BTW, memory block allocated by core.stdc.stdlib.malloc will not be scanned by collector, right? Unless you add it, no.
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 05:23:47 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 04:36:02 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote: [...] Looks like _d_arrayappendcTX asked for a enormous amount of memory and it fails, can't figure out why Just find out it's my own fault. BTW, memory block allocated by core.stdc.stdlib.malloc will not be scanned by collector, right? right, that's why it's annotated @nogc ;)
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 04:36:02 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote: [...] Looks like _d_arrayappendcTX asked for a enormous amount of memory and it fails, can't figure out why Just find out it's my own fault. BTW, memory block allocated by core.stdc.stdlib.malloc will not be scanned by collector, right?
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 03:37:39 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole wrote: On 07/04/2016 3:18 PM, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: [...] static this/static ~this should work, right? They execute when the runtime is started. So now I add call rt_init in the C shared library. Now the D library no longer gets SIGSEGV, but throws no memory exception when it tries to allocate. Back trace: (gdb) bt #0 0x7fffe19e006c in _d_throwdwarf () from /lib64/libphobos2.so.0.70 #1 0x7fffe19af2ab in onOutOfMemoryErrorNoGC () from /lib64/libphobos2.so.0.70 #2 0x7fffe19cbfa3 in gc.gc.GC.__T9runLockedS47_D2gc2gc2GC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS21_D2gc2gc10mallocTimelS21_D2gc2gc10numMallocslTmTkTmTxC8TypeInfoZ.runLocked() () from /lib64/libphobos2.so.0.70 #3 0x7fffe19c4f66 in gc.gc.GC.malloc() () from /lib64/libphobos2.so.0.70 #4 0x7fffe19cda18 in gc_qalloc () from /lib64/libphobos2.so.0.70 #5 0x7fffe19e17dd in rt.lifetime.__arrayAlloc() () from /lib64/libphobos2.so.0.70 #6 0x7fffe19e6445 in _d_arrayappendcTX () from /lib64/libphobos2.so.0.70 #7 0x7fffe19e5b47 in _d_arrayappendT () from /lib64/libphobos2.so.0.70 Looks like _d_arrayappendcTX asked for a enormous amount of memory and it fails, can't figure out why
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 03:37:39 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole wrote: On 07/04/2016 3:18 PM, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: [...] static this/static ~this should work, right? They execute when the runtime is started. So now I add call rt_init in the C shared library. Now the D library no longer gets SIGSEGV, but throws no memory exception when it tries to allocate. Back trace: (gdb) bt #0 0x7fffe19e006c in _d_throwdwarf () from /lib64/libphobos2.so.0.70 #1 0x7fffe19af2ab in onOutOfMemoryErrorNoGC () from /lib64/libphobos2.so.0.70 #2 0x7fffe19cbfa3 in gc.gc.GC.__T9runLockedS47_D2gc2gc2GC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS21_D2gc2gc10mallocTimelS21_D2gc2gc10numMallocslTmTkTmTxC8TypeInfoZ.runLocked() () from /lib64/libphobos2.so.0.70 #3 0x7fffe19c4f66 in gc.gc.GC.malloc() () from /lib64/libphobos2.so.0.70 #4 0x7fffe19cda18 in gc_qalloc () from /lib64/libphobos2.so.0.70 #5 0x7fffe19e17dd in rt.lifetime.__arrayAlloc() () from /lib64/libphobos2.so.0.70 #6 0x7fffe19e6445 in _d_arrayappendcTX () from /lib64/libphobos2.so.0.70 #7 0x7fffe19e5b47 in _d_arrayappendT () from /lib64/libphobos2.so.0.70
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole wrote: On 07/04/2016 3:18 PM, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: [...] static this/static ~this should work, right? They execute when the runtime is started. So now I add call rt_init in the C shared library. Now the D library no longer gets SIGSEGV, but throws no memory exception when it tries to allocate.
Re: Problem using shared D library from C shared library
On 07/04/2016 3:18 PM, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote: [...] The runtime is needed if you are going to use any of its features, like the GC. If you restrict yourself strictly to C in D (and that means avoiding thinks like builtin AAs, array concatenation, and anything that touches the runtime) you can do without it. The functions you want are core.runtime.rt_init for initialization and core.runtime.rt_term for cleanup [1]. On Windows, you can guarantee these will be called by adding a DLLMain checking for DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH. On other platforms, you'll need to work out something else. [1] http://dlang.org/phobos/core_runtime.html#.rt_init static this/static ~this should work, right? They execute when the runtime is started.
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote: [...] The runtime is needed if you are going to use any of its features, like the GC. If you restrict yourself strictly to C in D (and that means avoiding thinks like builtin AAs, array concatenation, and anything that touches the runtime) you can do without it. The functions you want are core.runtime.rt_init for initialization and core.runtime.rt_term for cleanup [1]. On Windows, you can guarantee these will be called by adding a DLLMain checking for DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH. On other platforms, you'll need to work out something else. [1] http://dlang.org/phobos/core_runtime.html#.rt_init static this/static ~this should work, right?
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote: On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote: [...] The runtime is needed if you are going to use any of its features, like the GC. If you restrict yourself strictly to C in D (and that means avoiding thinks like builtin AAs, array concatenation, and anything that touches the runtime) you can do without it. The functions you want are core.runtime.rt_init for initialization and core.runtime.rt_term for cleanup [1]. On Windows, you can guarantee these will be called by adding a DLLMain checking for DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH. On other platforms, you'll need to work out something else. [1] http://dlang.org/phobos/core_runtime.html#.rt_init Thanks a lot. I wish this can be better documented, though.
Re: Build release and debug with dub
On Thursday, 7 April 2016 at 02:07:18 UTC, Puming wrote: On Wednesday, 6 April 2016 at 19:49:38 UTC, Suliman wrote: [...] In the document it says you can not specify targetName in buildType. I wonder why is that? But you can use two configurations like this(assumming your project is named "App"): ``` configuration "App" { targetType "executable" targetName "hello" typo: "hello" -> "App" } configuration "AppDebug" { targetType "executable" targetName "AppDebug" } ``` and use `dub -c AppDebug` for AppDebug.exe, and `dub -b release` for App.exe
Re: Build release and debug with dub
On Wednesday, 6 April 2016 at 19:49:38 UTC, Suliman wrote: Is it's possible to make rule, that allow to build two version of App? One release and one debug at same time. I looked at "buildTypes" https://code.dlang.org/package-format?lang=json But it's not possible to set different names for output files. I want to build App.exe and AppDebug.exe after simple command dub build. In the document it says you can not specify targetName in buildType. I wonder why is that? But you can use two configurations like this(assumming your project is named "App"): ``` configuration "App" { targetType "executable" targetName "hello" } configuration "AppDebug" { targetType "executable" targetName "AppDebug" } ``` and use `dub -c AppDebug` for AppDebug.exe, and `dub -b release` for App.exe
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 01:42:54 UTC, rikki cattermole wrote: On 07/04/2016 1:38 PM, Yuxuan Shui wrote: [...] Have you started D's runtime? How to start D's runtime? I followed the examples found here: https://dlang.org/dll-linux.html#dso9, which doesn't say anything about starting the runtime. The runtime is needed if you are going to use any of its features, like the GC. If you restrict yourself strictly to C in D (and that means avoiding thinks like builtin AAs, array concatenation, and anything that touches the runtime) you can do without it. The functions you want are core.runtime.rt_init for initialization and core.runtime.rt_term for cleanup [1]. On Windows, you can guarantee these will be called by adding a DLLMain checking for DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH. On other platforms, you'll need to work out something else. [1] http://dlang.org/phobos/core_runtime.html#.rt_init
Re: Problem using shared D library from C shared library
On Thursday, 7 April 2016 at 01:42:54 UTC, rikki cattermole wrote: On 07/04/2016 1:38 PM, Yuxuan Shui wrote: [...] Have you started D's runtime? How to start D's runtime? I followed the examples found here: https://dlang.org/dll-linux.html#dso9, which doesn't say anything about starting the runtime.
Re: Putting things in an enum's scope
On Wednesday, 6 April 2016 at 13:59:42 UTC, pineapple wrote: Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? It can sometimes help with code organization. For example, this is something that coming from Java I'd have expected to be valid but isn't: enum SomeEnum{ NORTH, SOUTH, EAST, WEST; static int examplestaticmethod(in int x){ return x + 2; } } int z = SomeEnum.examplestaticmethod(2); Java's enums are classes, which is why that works. Nothing in Java can exist outside of a class. D's enums are like those in C. They do not define objects, just constant values.
Re: Problem using shared D library from C shared library
On 07/04/2016 1:38 PM, Yuxuan Shui wrote: I have a D shared library which is loaded by a C shared library, which is in turn loaded by my main program. When the D library tries to allocate something, the whole program get an SIGSEGV in __GI___pthread_mutex_lock. Stack trace: (gdb) bt #0 __GI___pthread_mutex_lock (mutex=0x7fffc1b8) at ../nptl/pthread_mutex_lock.c:66 #1 0x7fffe19cbeef in gc.gc.GC.__T9runLockedS47_D2gc2gc2GC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS21_D2gc2gc10mallocTimelS21_D2gc2gc10numMallocslTmTkTmTxC8TypeInfoZ.runLocked() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #2 0x7fffe19c4f66 in gc.gc.GC.malloc() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #3 0x7fffe19cda18 in gc_qalloc () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #4 0x7fffe19e17dd in rt.lifetime.__arrayAlloc() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #5 0x7fffe19e6d26 in _d_arrayliteralTX () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 What can be the problem? Have you started D's runtime?
Problem using shared D library from C shared library
I have a D shared library which is loaded by a C shared library, which is in turn loaded by my main program. When the D library tries to allocate something, the whole program get an SIGSEGV in __GI___pthread_mutex_lock. Stack trace: (gdb) bt #0 __GI___pthread_mutex_lock (mutex=0x7fffc1b8) at ../nptl/pthread_mutex_lock.c:66 #1 0x7fffe19cbeef in gc.gc.GC.__T9runLockedS47_D2gc2gc2GC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS21_D2gc2gc10mallocTimelS21_D2gc2gc10numMallocslTmTkTmTxC8TypeInfoZ.runLocked() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #2 0x7fffe19c4f66 in gc.gc.GC.malloc() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #3 0x7fffe19cda18 in gc_qalloc () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #4 0x7fffe19e17dd in rt.lifetime.__arrayAlloc() () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 #5 0x7fffe19e6d26 in _d_arrayliteralTX () from /var/services/homes/.../install/linux/lib64/libphobos2.so.0.70 What can be the problem?
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 23:14:10 UTC, Jonathan Villa wrote: On Wednesday, 6 April 2016 at 21:33:14 UTC, Alex Parrill wrote: My general idea is first to get the predicted quantity of combinations Seems like you already know; your OP says you have 2^n combinations. so I can divide and parallelize them. std.parallelism.parallel can do this for you, and works on ranges. http://dlang.org/phobos/std_parallelism.html#.parallel What do you think can be the problem with the lack of deallocation? Don't know exactly. destroy just runs the destructors, it doesn't free any memory. Since the arrays are still in scope, it might not be able to free them.
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 21:33:14 UTC, Alex Parrill wrote: On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a ... Why not make a range instead? No need to reserve memory for the entire array if you can compute the elements as-needed. If you really want an array, std.experimental.allocator will let you manually allocate/release objects. I'm going to try use a custom allocator for tomorrow. My general idea is first to get the predicted quantity of combinations so I can divide and parallelize them. What do you think can be the problem with the lack of deallocation? Regards.
Re: Putting things in an enum's scope
On Wednesday, 6 April 2016 at 13:59:42 UTC, pineapple wrote: Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? It can sometimes help with code organization. For example, this is something that coming from Java I'd have expected to be valid but isn't: enum SomeEnum{ NORTH, SOUTH, EAST, WEST; static int examplestaticmethod(in int x){ return x + 2; } } int z = SomeEnum.examplestaticmethod(2); You can use UFCS: enum SomeEnum { NORTH, ... } int examplestaticmethod(in SomeEnum e) { return e+2; } SomeEnum.NORTH.examplestaticmethod();
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). ... Why not make a range instead? No need to reserve memory for the entire array if you can compute the elements as-needed. If you really want an array, std.experimental.allocator will let you manually allocate/release objects.
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a TL;DR: My program generates a very large `ubyte[][]`, and after I call destroy and GC.collect() and GC.minimize(), the memory occuping doesn't seems to decrease.
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Sample code. void main() { while(true) { write("Alternatives quantity: "); string value = chomp(readln()); if (value == "x") break; int x = to!int(value); ubyte[][] combs = GenerateCombinations(x); writefln("There are %d combinations.", combs.length); foreach(ubyte[] a; combs) destroy(a); destroy(combs); writeln(); GC.collect(); GC.minimize(); } return; }
Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 19:22:44 UTC, Daniel Kozak wrote: This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal uživatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com>: Thanks for the answers. Kind regards André
Best properly way to destroy a 2 dimensional array?
I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Now the problem is, the quantity of combinations generated are pow(2, `x`), thus, giving 20 it returns me a list of 1_048_576 arrays of ubyte, every array has length of `x` so, in the end this function allocates (seeing the Windows Task Manager) 42 MB of data after input `20` the first time. When the list is ready it prints the quantity of combinations given (combinations.length), after that I added a foreach(ubyte[] a; combinations) calling destroy to every array and then destroy(combinations), and before to re-input a new number to generate a new combination list I call GC.Collect() and GC.minimize(). My question is if I'm doing good calling destroy to those arrays, because I don't see any change in the quantity of memory the program is using: In the start it uses 1496 KB, after input `20` it now have 43000 KB (approx.) and if I input again 20 then it sums up to 9 KB. In the end I don't see some kind of real memory free. I'm doing something wrong? That's the reason I'm asking for your advice. PD: All arrays are constructed with the `new` expression. PD2: Don't ask me why I don't better do an `int count` instead of constructing arrays, this little program is going to be part of a more huge application and I need the combination list. Regards. JV
Build release and debug with dub
Is it's possible to make rule, that allow to build two version of App? One release and one debug at same time. I looked at "buildTypes" https://code.dlang.org/package-format?lang=json But it's not possible to set different names for output files. I want to build App.exe and AppDebug.exe after simple command dub build.
Re: Issue with 2.071: Regression or valid error?
This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal uživatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com>: > Hi, > > With 2.071 following coding does not compile anymore and somehow I feel it > should compile. > The issue is with line "cat.create();". > Cat is a sub type of Animal. Animal "owns" method create and I want to > call the method > create within the class Animal for cat. > > Is the error message "no property create for type 'b.cat'" valid or not? > > Kind regards > André > > module a; > import b; > > class Animal > { > private void create() {} > > void foo(Cat cat) > { > cat.create(); // >> no property create for type 'b.cat' > } > } > > void main() {} > > -- > > module b; > import a; > > class Cat: Animal {}; > > compile with > >> rdmd a b >>> >>
Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 19:01:58 UTC, Craig Dillabaugh wrote: On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote: clip Not so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create(). You CAN'T typically access a private ...
Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote: Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards André module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -- module b; import a; class Cat: Animal {}; compile with rdmd a b Not so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create().
Issue with 2.071: Regression or valid error?
Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards André module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -- module b; import a; class Cat: Animal {}; compile with rdmd a b
Re: Putting things in an enum's scope
On Wednesday, 6 April 2016 at 13:59:42 UTC, pineapple wrote: Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? No. You could make a struct rather than an enum though with the methods, and a bunch of static things to simulate SomeEnum.NORTH.
Putting things in an enum's scope
Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? It can sometimes help with code organization. For example, this is something that coming from Java I'd have expected to be valid but isn't: enum SomeEnum{ NORTH, SOUTH, EAST, WEST; static int examplestaticmethod(in int x){ return x + 2; } } int z = SomeEnum.examplestaticmethod(2);
Re: What's the rationale for considering "0x1.max" as invalid ?
On Tuesday, 5 April 2016 at 21:40:59 UTC, Basile B. wrote: On Tuesday, 5 April 2016 at 21:10:47 UTC, Basile B. wrote: On Tuesday, 5 April 2016 at 20:56:54 UTC, Alex Parrill wrote: On Tuesday, 5 April 2016 at 19:00:43 UTC, Basile B. wrote: 0x1.max // exponent expected in hex float 0x1 .max // OK 1.max // OK What's the ambiguity when it's an hex literal ? It's potentially ambiguous with hexadecimal floating point numbers 0xdeadbeef.p5 // hex float or hex int + method? dlang.org/spec/lex.html#HexFloat Yes but it's pointless to allow the decimal separator to be followed by the exponent: void main() { import std.stdio; writeln( typeof(0x1p5).stringof ); // double writeln( typeof(0x1.p5).stringof ); // double } I mean that the rule could be: the decimal separator must be followed by a second group of digits. The second group of digits must be followed by an exponent. The first group of digits can be followed by an exponent. 0x1.0p5 // valid 0xp5 // valid 0x1.p5 // invalid (p is not a hex digit) 0x1.ap5 // valid Looks like that's how it works for decimal floats; I.e. 1.e5 is an int and property lookup, while 1.0e5 is 10f. Curiously, 1. Is 1.0. I agree that floats should be parsed consistently. For now, you can do (0x1).max or typeof(0x1).max.
Re: What is the best way to store bitarray (blob) for pasting in database?
On Wednesday, 6 April 2016 at 12:56:39 UTC, Suliman wrote: I have next task. There is PostgreSQL DB. With field like: id, mydata. mydata - is binary blob. It can be 10MB or even more. I need load all data from PostgreSQL to SQLLite. I decided ti create struct that and fill it with data. And then do INSERT operation in sqllite. But I do not know is it's good way, and if it's ok what data type should I use for blob (binary data). struct MyData { string id; string mydata; // what datatype I should use here?? } MyData [] mydata; MyData md; while (rs.next()) { md.id = to!string(rs.getString(1)); md.mydata = to!string(rs.getString(2)); //?? mydata ~= md; } stmtLite.executeUpdate(`insert into MySyncData(id,mydata) values(md.id,md.data)`); //ddbc driver is it's normal way to insert data? Blobs are byte arrays, so they should be ubyte[]. They shouldn't be strings, which are explicitly text only.
What is the best way to store bitarray (blob) for pasting in database?
I have next task. There is PostgreSQL DB. With field like: id, mydata. mydata - is binary blob. It can be 10MB or even more. I need load all data from PostgreSQL to SQLLite. I decided ti create struct that and fill it with data. And then do INSERT operation in sqllite. But I do not know is it's good way, and if it's ok what data type should I use for blob (binary data). struct MyData { string id; string mydata; // what datatype I should use here?? } MyData [] mydata; MyData md; while (rs.next()) { md.id = to!string(rs.getString(1)); md.mydata = to!string(rs.getString(2)); //?? mydata ~= md; } stmtLite.executeUpdate(`insert into MySyncData(id,mydata) values(md.id,md.data)`); //ddbc driver is it's normal way to insert data?