Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 03, 2018 Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
what is best (SQLite?) @small @local @offline database library to use in D? and also what about a simple GUI library ? (once there was a library named DFL, but i never could get it to run). |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to wakhshti | On Wednesday, 3 January 2018 at 12:14:19 UTC, wakhshti wrote: > > what is best (SQLite?) @small @local @offline database library to use in D? > > and also what about a simple GUI library ? (once there was a library named DFL, but i never could get it to run). As you proposed SQLite makes sense. My personal preference is the wrapper from Adam you can find here https://github.com/adamdruppe/arsd/blob/master/sqlite.d Do you want to run on a specific OS only or should it run on multiple OS? There is also the Learn forum which fits better for beginner questions. Kind regards Andre |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to wakhshti | On Wednesday, 3 January 2018 at 12:14:19 UTC, wakhshti wrote: > > what is best (SQLite?) @small @local @offline database library to use in D? > > and also what about a simple GUI library ? (once there was a library named DFL, but i never could get it to run). I've used sqlite3 library: http://code.dlang.org/packages/sqlite3 and it has worked well for me. Documentation is brief, but has a clean API and relatively easy to use. However, there is small bug in the support for floating point values if you need that. I submitted a patch but don't think it has made its way into the main repository. |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to wakhshti | On Wed, Jan 03, 2018 at 12:14:19PM +0000, wakhshti via Digitalmars-d wrote: > > what is best (SQLite?) @small @local @offline database library to use > in D? [...] I've been using SQLite for this type of usage, and it's served me pretty well. I've been using Adam Ruppe's SQLite bindings: https://github.com/adamdruppe/arsd/blob/master/sqlite.d which is very nice, lightweight, and doesn't have heavy dependencies (all you need is database.d and sqlite.d, plop them into a subdirectory called arsd, and then just `import arsd.sqlite` and you're all set to go). Recently, though, I decided to write my own bindings due to certain design decisions in Adam's sqlite.d that made it a little awkward to use for my particular application. My bindings are now usable for basic database operation and have a rather nice API, if I do say so myself (well, it is modelled after Adam's sqlite.d which already has a nice and simple API), but feature-wise it's still quite bare (doesn't support precompiled SQL statements yet). The current main features are: - Basic database operation: open a database file, execute SQL statements (on par with Adam's sqlite.d). - Automatic binding (on par with Adam's sqlite.d), e.g.: long id = 123; string name = "abc"; auto rs = db.query("SELECT * FROM product WHERE id=? AND name=?", id, name); - Supports binding floating-point values. - Supports binary blobs in the form of ubyte[]. - Supports integers up to signed 64-bit (long). - Supports nested transactions (via SAVEPOINT and RELEASE). - Range-based API for iterating over result sets. - Convenient automatic conversions to/from SQLite data types, e.g.: float maxPrice = 100.00; auto rs = db.query("SELECT count, price FROM product WHERE price < ?", maxPrice); foreach (row; rs) { int count = row[0].to!int; float price = row[1].to!float; } - Fully-automated transcription of result sets to array of structs, or individual rows to structs, and convenience functions for extracting single-column result sets into an array of scalar values, or individual single-column rows into scalar values. Example: struct S { int name; float price; ubyte[] image; // BLOB } // Transcribe individual rows to struct foreach (row; db.query("SELECT name,price,image FROM product")) { S s = row.to!S; } // Transcribe entire result set to array of structs S[] results = db.query("SELECT name,price,image FROM product") .to!(S[]); If you wish, I can give you a copy of the code -- it's just a single file that you can import directly, no other dependencies besides the SQLite library itself. It's not quite in the shape to be posted to a public repository like github just yet, but depending on what you need, it might be good enough. T -- An elephant: A mouse built to government specifications. -- Robert Heinlein |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Pany | On Wednesday, 3 January 2018 at 12:45:51 UTC, Andre Pany wrote: > > As you proposed SQLite makes sense. My personal preference is the wrapper from Adam you can find here https://github.com/adamdruppe/arsd/blob/master/sqlite.d > > Do you want to run on a specific OS only or should it run on multiple OS? > > There is also the Learn forum which fits better for beginner questions. > > Kind regards > Andre i downloaded the whole arsd and unzipped to folder that my main.d is. and main.d contents are: >import std.stdio; >import arsd.sqlite; > > >void main(string[] args) { > > Database db = new Sqlite("test.sqlite.db"); > > /+ > db.query("CREATE TABLE users (id integer, name text)"); > db.query("INSERT INTO users values (?, ?)", 1, "hello"); > foreach(line; db.query("SELECT * FROM users")) { > writefln("%s %s", line[0], line["name"]); > } > +/ >} i get this error: D:\ashit\document\DlangIDE\database\database\source>dmd main.d OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html main.obj(main) Error 42: Symbol Undefined _D4arsd6sqlite6Sqlite6__ctorMFAyaiZCQBiQBgQBc main.obj(main) Error 42: Symbol Undefined _D4arsd6sqlite6Sqlite7__ClassZ main.obj(main) Error 42: Symbol Undefined _D4arsd6sqlite12__ModuleInfoZ Error: linker exited with status 3 ----------------------------------------------------------------- the os i use is Windows7 (dual boot with ubuntu but mainly on windows7) also i tried several libraries. i couldn't run any database or gui libraries correctly so far. dlangui was the only gui library that i was able to run correctly. im interested in DFL and Entice designer (never be able to run them either) |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to wakhshti | On Wednesday, 3 January 2018 at 20:39:59 UTC, wakhshti wrote: > Error 42: Symbol Undefined _D4arsd6sqlite6Sqlite6__ctorMFAyaiZCQBiQBgQBc That means you didn't link in the module. The way I recommend doing it is listing them all on the command line: dmd yourfile.d database.d sqlite.d or if you put them in an arsd folder (optional) dmd yourfile.d arsd\database.d arsd\sqlite.d For sqlite, you also will need a sqlite.lib in the current directory or it will list a lot of Symbol Undefined like _sqlite3_open etc. And at runtime, you will need the sqlite.dll file along with your exe. This is probably your general problem: you need to link in those libs too. Here's the sqlite3.lib and dll too if you don't already have them: http://arsdnet.net/dcode/sqlite3.lib http://arsdnet.net/dcode/sqlite3.dll just download them to the folder with your program. |
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 3 January 2018 at 20:52:49 UTC, Adam D. Ruppe wrote:
> Here's the sqlite3.lib and dll too if you don't already have them:
These are just for Windows btw (and for that, only 32 bit. if you are building 64 bit that is different, I have never used sqlite on 64 bit windows. but 32 bit is usually good enough anyway)
On Linux, you just need to make sure the sqlite3-devel package is installed. I think that's what it is called too, so apt-get install sqlite3-devel. if not it might suggest the right name
|
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Wednesday, 3 January 2018 at 19:08:44 UTC, H. S. Teoh wrote:
> Recently, though, I decided to write my own bindings due to certain design decisions in Adam's sqlite.d that made it a little awkward to use for my particular application.
I'm open to extensions and PRs... I don't remember if we have already talked about this but if not email me destructionator@gmail.com and we'll see if we can't merge again.
I know you have had some trouble with the classes before, maybe we can work out a more deterministic design there.
|
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to wakhshti | On Wednesday, 3 January 2018 at 20:39:59 UTC, wakhshti wrote:
> On Wednesday, 3 January 2018 at 12:45:51 UTC, Andre Pany wrote:
>>
>> As you proposed SQLite makes sense. My personal preference is the wrapper from Adam you can find here https://github.com/adamdruppe/arsd/blob/master/sqlite.d
>>
>> Do you want to run on a specific OS only or should it run on multiple OS?
>>
>> There is also the Learn forum which fits better for beginner questions.
>>
>> Kind regards
>> Andre
>
> i downloaded the whole arsd and unzipped to folder that my main.d is.
>
> and main.d contents are:
>
>
>>import std.stdio;
>>import arsd.sqlite;
>>
>>
>>void main(string[] args) {
>>
>> Database db = new Sqlite("test.sqlite.db");
>>
>> /+
>> db.query("CREATE TABLE users (id integer, name text)");
>> db.query("INSERT INTO users values (?, ?)", 1, "hello");
>> foreach(line; db.query("SELECT * FROM users")) {
>> writefln("%s %s", line[0], line["name"]);
>> }
>> +/
>>}
>
>
> i get this error:
>
> D:\ashit\document\DlangIDE\database\database\source>dmd main.d
> OPTLINK (R) for Win32 Release 8.00.17
> Copyright (C) Digital Mars 1989-2013 All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> main.obj(main)
> Error 42: Symbol Undefined _D4arsd6sqlite6Sqlite6__ctorMFAyaiZCQBiQBgQBc
> main.obj(main)
> Error 42: Symbol Undefined _D4arsd6sqlite6Sqlite7__ClassZ
> main.obj(main)
> Error 42: Symbol Undefined _D4arsd6sqlite12__ModuleInfoZ
> Error: linker exited with status 3
>
>
> -----------------------------------------------------------------
> the os i use is Windows7 (dual boot with ubuntu but mainly on windows7)
> also i tried several libraries. i couldn't run any database or gui libraries correctly so far.
> dlangui was the only gui library that i was able to run correctly.
> im interested in DFL and Entice designer (never be able to run them either)
You have to pass all source files you wish to compile to dmd.
|
January 03, 2018 Re: Best SQL library to use with local desktop app | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Dillabaugh | On Wednesday, 3 January 2018 at 16:38:27 UTC, Craig Dillabaugh wrote: > On Wednesday, 3 January 2018 at 12:14:19 UTC, wakhshti wrote: >> >> what is best (SQLite?) @small @local @offline database library to use in D? >> >> and also what about a simple GUI library ? (once there was a library named DFL, but i never could get it to run). > > I've used sqlite3 library: > > http://code.dlang.org/packages/sqlite3 > > and it has worked well for me. Documentation is brief, but has a clean API and relatively easy to use. However, there is small bug in the support for floating point values if you need that. I submitted a patch but don't think it has made its way into the main repository. yes, it is very good looking API. interesting i downloaded and extracted files into my main.d file directory this is main.d content: >import std.stdio; >import sqlite; > >void main(string[] args){ > > auto db = new SQLite3("datafile.db"); > >} when i run : >dmd main.d i get this error: D:\ashit\document\DlangIDE\database\db>dmd main.d OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html main.obj(main) Error 42: Symbol Undefined _D6sqlite7SQLite36__ctorMFAyaZCQBdQz main.obj(main) Error 42: Symbol Undefined _D6sqlite7SQLite37__ClassZ Error: linker exited with status 2 what to do ? i also downloaded new dmd but nothing seems going well. |
Copyright © 1999-2021 by the D Language Foundation