View mode: basic / threaded / horizontal-split · Log in · Help
April 30, 2012
Re: mysql binding/wrapper?
On 4/30/12 11:57 PM, simendsjo wrote:
On 4/29/12 11:48 PM, dnewbie wrote:
> On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote:
> stuff/blob/master/mysql.d
>> http://my.opera.com/run3/blog/2012/03/13/d-mysql
>
> I use it in a bank account application. It works.

> On Mon, 30 Apr 2012 18:19:29 +0200, James Oliphant
> <jollie.roger@gmail.com> wrote:
>
>> Actually, it looks like the vibe folks are using my fork of Steve Teales
>> mysqln. I had hoped to contact Steve first, so that these changes existed
>> in one place.
>> https://github.com/JollieRoger
>> All of the changes exist in individual branches off the master branch.
>> Git
>> will merge these into one file fuzzily.
>> What they are is as follows:
>> seperatemain - split main() into its own file (app.d in vibe).
>> seperatemainwithport - main() using branch addporttoconnection.
>> addporttoconnection - add no standard port selection to Connection.
>> fixfordmd2058 - cosmetic changes to work with dmd-2.058.
>> fixresultset - allow the return of an empty resultset. When
>> iterating schema, test had no tables and would crash.
>> fixconnection - would only connect to localhost in Steve's code.
>> I have other changes that I haven't pushed up yet relating to NUMERIC and
>> null variants with a more detailed main.d.
>> Vibe.d looks interesting, I hope these fixes help.
>
> Yes, your patches has been merged. Of course it would be best to have
> everything database complete already, but I'm glad it's been merged
> as-is for now - it might take a long time (and has already) before a
> generic database interface is completed.

Looking at the code of mysql.d I see a big switch with many cases like 
"case  0x01:  // TINYINT". But then there's the SQLType enum with those 
constants. Why the enum values are not used in the cases? (and also in 
other parts of the code?)
April 30, 2012
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 20:53:02 +0200, James Oliphant  
<jollie.roger@gmail.com> wrote:

> On Mon, 30 Apr 2012 18:57:57 +0200, simendsjo wrote:
>
>> Yes, your patches has been merged. Of course it would be best to have
>> everything database complete already, but I'm glad it's been merged
>> as-is for now - it might take a long time (and has already) before a
>> generic database interface is completed.
>
> Hi simendsjo,
>
> I now see your repository at:
> https://github.com/simendsjo/mysqln
>
> Is there a way that we can have one central repository that people can
> pull from. I would like it to be Steve's since that is the one everybody
> knows, but I am not sure he wants to manage pull requests and such (If
> your are listening Steve, please weigh in). He seems to be enjoying
> "Adventures in Woodworking" and may not have any fingers left when he
> finishes his latest project (just joking, read your blog). Otherwise,
> maybe we could use your repository listed above.
>
> My goal is not a generic database interface discussed previously in these
> groups. I just want an interface for mysql/mariadb and less so for
> postgresql at this point.

I did a small patch for it to compile for x64.
Vibe.d has patches to use it's internal stream library, so that would  
probably be hard to patch back to Steve.
I was thinking of deleting my project and forking from vibe.d to do pull  
requests against that as I thought that would be the most used repository
Not sure how we should go about this, but I agree fragmentation is bad.

Hope Steve can chip in as it's his code and he has plans for a generic  
interface.
April 30, 2012
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana <ary@esperanto.org.ar>  
wrote:
> Looking at the code of mysql.d I see a big switch with many cases like  
> "case  0x01:  // TINYINT". But then there's the SQLType enum with those  
> constants. Why the enum values are not used in the cases? (and also in  
> other parts of the code?)

It's not finished: http://www.britseyeview.com/software/mysqln/
May 01, 2012
Frustration [Was: mysql binding/wrapper?]
On 5/1/12 2:44 AM, simendsjo wrote:
> On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana <ary@esperanto.org.ar>
> wrote:
>> Looking at the code of mysql.d I see a big switch with many cases like
>> "case 0x01: // TINYINT". But then there's the SQLType enum with those
>> constants. Why the enum values are not used in the cases? (and also in
>> other parts of the code?)
>
> It's not finished: http://www.britseyeview.com/software/mysqln/

Ah, I see.

The last commit is 6 months old.

I tried to compile mysql.d

---
> dmd -c mysql.d
/usr/share/dmd/src/phobos/std/exception.d(492): Error: constructor 
mysql.MySQLException.this (string msg, string file, uint line) is not 
callable using argument types (string,string,ulong)
/usr/share/dmd/src/phobos/std/exception.d(492): Error: cannot implicitly 
convert expression (line) of type ulong to uint
mysql.d(105): Error: template instance 
std.exception.enforceEx!(MySQLException).enforceEx!(ulong) error 
instantiating
(...)
(and more...)
---

It's sad. I always want to give D a chance. And when I do I always bump 
into errors and inconveniences.

I thought, maybe the project is 6 months old, it's not compatible 
anymore with the current DMD (but my code really doesn't break at all 
with new Ruby versions, for example). I thought of trying to fix the 
error. Apparently I need to compile it with -m32 so that lengths of 
arrays are uint instead of ulong.

---
> dmd -c -m32 mysql.d
mysql.d(4185): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong)
mysql.d(4201): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong)
mysql.d(4204): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong)
---

(What does it mean "cannot cast"? Give me the reason, please...)

Or maybe instead of the flag the code is wrong and instead of uint it 
needs to be size_t. But I still get errors.

Every time I want to start coding in D, or helping some project, I 
stumble into all kind of troubles.

But I wonder... is this case in particular D's fault or the library's 
fault? (if the answer is "the project is 6 months old, of course it 
won't compile" then it's D's fault)
May 01, 2012
Re: Frustration [Was: mysql binding/wrapper?]
On Tue, 01 May 2012 04:04:01 +0200, Ary Manzana <ary@esperanto.org.ar>  
wrote:
> It's sad. I always want to give D a chance. And when I do I always bump  
> into errors and inconveniences.
(...)
> Every time I want to start coding in D, or helping some project, I  
> stumble into all kind of troubles.

I have the same feeling. I used D quite a lot around 1.007-1.0028, and  
every library broke with each release. And new bugs were introduced each  
release. It was a big PITA.
It seems the situation has gotten a lot better, so I hope I'll be able to  
use D for a small project now.

As for mysqln, I merged jrogers patches and changed uint to size_t so it  
compiles on x64.
You can look at it here:  
https://github.com/simendsjo/mysqln/tree/compile-on-recent-dmd
It hasn't been tested beyond connecting to the database and fetching  
metadata yet.
And my repository will go away very soon as I'll rather help with the  
original library (if Steve Teale comes back) or the one in vibe.
May 01, 2012
Re: Frustration [Was: mysql binding/wrapper?]
On Tuesday, 1 May 2012 at 02:04:03 UTC, Ary Manzana wrote:
> On 5/1/12 2:44 AM, simendsjo wrote:
>> On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana 
>> <ary@esperanto.org.ar>
>> wrote:
>>> Looking at the code of mysql.d I see a big switch with many 
>>> cases like
>>> "case 0x01: // TINYINT". But then there's the SQLType enum 
>>> with those
>>> constants. Why the enum values are not used in the cases? 
>>> (and also in
>>> other parts of the code?)
>>
>> It's not finished: http://www.britseyeview.com/software/mysqln/
>
> Ah, I see.
>
> The last commit is 6 months old.
>
> I tried to compile mysql.d
>
> ---
> > dmd -c mysql.d
> /usr/share/dmd/src/phobos/std/exception.d(492): Error: 
> constructor mysql.MySQLException.this (string msg, string file, 
> uint line) is not callable using argument types 
> (string,string,ulong)
> /usr/share/dmd/src/phobos/std/exception.d(492): Error: cannot 
> implicitly convert expression (line) of type ulong to uint
> mysql.d(105): Error: template instance 
> std.exception.enforceEx!(MySQLException).enforceEx!(ulong) 
> error instantiating
> (...)
> (and more...)
> ---
>
> It's sad. I always want to give D a chance. And when I do I 
> always bump into errors and inconveniences.
>
> I thought, maybe the project is 6 months old, it's not 
> compatible anymore with the current DMD (but my code really 
> doesn't break at all with new Ruby versions, for example). I 
> thought of trying to fix the error. Apparently I need to 
> compile it with -m32 so that lengths of arrays are uint instead 
> of ulong.
>
> ---
> > dmd -c -m32 mysql.d
> mysql.d(4185): Error: cannot cast 
> r.opIndex(cast(uint)j).get!(ulong)
> mysql.d(4201): Error: cannot cast 
> r.opIndex(cast(uint)j).get!(ulong)
> mysql.d(4204): Error: cannot cast 
> r.opIndex(cast(uint)j).get!(ulong)
> ---
>
> (What does it mean "cannot cast"? Give me the reason, please...)
>
> Or maybe instead of the flag the code is wrong and instead of 
> uint it needs to be size_t. But I still get errors.
>
> Every time I want to start coding in D, or helping some 
> project, I stumble into all kind of troubles.
>
> But I wonder... is this case in particular D's fault or the 
> library's fault? (if the answer is "the project is 6 months 
> old, of course it won't compile" then it's D's fault)

Ah, finally, someone has found Steve Teale's batcave. It seems 
that you are not too far from having it compiled. If you end up 
succeeding, maybe you can propose him to update his file, so that 
we can benefit ?

Looking at his code, it seems to me that he is very far from the 
original goal, which was to make a generic database driver. This 
one seems completely linked to MySQL and will need to be 
completely rewritten for Postgres. Am I wrong ?
May 01, 2012
Re: Frustration [Was: mysql binding/wrapper?]
On Tuesday, 1 May 2012 at 08:40:27 UTC, SomeDude wrote:
> On Tuesday, 1 May 2012 at 02:04:03 UTC, Ary Manzana wrote:
>> On 5/1/12 2:44 AM, simendsjo wrote:
>>> On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana 
>>> <ary@esperanto.org.ar>
>>> wrote:
>>>> Looking at the code of mysql.d I see a big switch with many 
>>>> cases like
>>>> "case 0x01: // TINYINT". But then there's the SQLType enum 
>>>> with those
>>>> constants. Why the enum values are not used in the cases? 
>>>> (and also in
>>>> other parts of the code?)
>>>
>>> It's not finished: 
>>> http://www.britseyeview.com/software/mysqln/
>>
>> Ah, I see.
>>
>> The last commit is 6 months old.
>>
>> I tried to compile mysql.d
>>
>> ---
>> > dmd -c mysql.d
>> /usr/share/dmd/src/phobos/std/exception.d(492): Error: 
>> constructor mysql.MySQLException.this (string msg, string 
>> file, uint line) is not callable using argument types 
>> (string,string,ulong)
>> /usr/share/dmd/src/phobos/std/exception.d(492): Error: cannot 
>> implicitly convert expression (line) of type ulong to uint
>> mysql.d(105): Error: template instance 
>> std.exception.enforceEx!(MySQLException).enforceEx!(ulong) 
>> error instantiating
>> (...)
>> (and more...)
>> ---
>>
>> It's sad. I always want to give D a chance. And when I do I 
>> always bump into errors and inconveniences.
>>
>> I thought, maybe the project is 6 months old, it's not 
>> compatible anymore with the current DMD (but my code really 
>> doesn't break at all with new Ruby versions, for example). I 
>> thought of trying to fix the error. Apparently I need to 
>> compile it with -m32 so that lengths of arrays are uint 
>> instead of ulong.
>>
>> ---
>> > dmd -c -m32 mysql.d
>> mysql.d(4185): Error: cannot cast 
>> r.opIndex(cast(uint)j).get!(ulong)
>> mysql.d(4201): Error: cannot cast 
>> r.opIndex(cast(uint)j).get!(ulong)
>> mysql.d(4204): Error: cannot cast 
>> r.opIndex(cast(uint)j).get!(ulong)
>> ---
>>
>> (What does it mean "cannot cast"? Give me the reason, 
>> please...)
>>
>> Or maybe instead of the flag the code is wrong and instead of 
>> uint it needs to be size_t. But I still get errors.
>>
>> Every time I want to start coding in D, or helping some 
>> project, I stumble into all kind of troubles.
>>
>> But I wonder... is this case in particular D's fault or the 
>> library's fault? (if the answer is "the project is 6 months 
>> old, of course it won't compile" then it's D's fault)
>
> Ah, finally, someone has found Steve Teale's batcave. It seems 
> that you are not too far from having it compiled. If you end up 
> succeeding, maybe you can propose him to update his file, so 
> that we can benefit ?
>
> Looking at his code, it seems to me that he is very far from 
> the original goal, which was to make a generic database driver. 
> This one seems completely linked to MySQL and will need to be 
> completely rewritten for Postgres. Am I wrong ?

OK, never mind, I should have read before jumping in. I asked 
where this code was a few weeks ago, and got no answer, so I'm 
quite glad that this comes up. I haven't tested the driver, but 
at least, it compiles fine.
May 01, 2012
Re: mysql binding/wrapper?
On Saturday, 28 April 2012 at 17:42:42 UTC, Adam D. Ruppe wrote:
> On Saturday, 28 April 2012 at 16:19:37 UTC, simendsjo wrote:
>> As it resides in this big misc repository, does it have many 
>> dependecies?
>
> It depends on the database.d module in there too. (database.d
> provides the base interface and some common functions with
> other db providers.)
>
> That's it though, D wise. It also uses the mysql C library
> so you'll need libmysql on your system for it to link too.
>
>> Would you mind if the module was added to vibe, and thus 
>> relicensed to MIT? No idea if the vibe folks would actually 
>> want that though :)
>
> My stuff is all free to take as far as I'm concerned, but
> since this uses libmysql it might technically be GPL.
>
> I don't really know. But if you're ok with that, you can have 
> it.

There is one small compilation error on the postgres driver line 
44. I'm not sure it's the right thing to do but changing the 
offending type to size_t seems to do the trick.
May 10, 2012
Re: Frustration [Was: mysql binding/wrapper?]
>
> As for mysqln, I merged jrogers patches and changed uint to 
> size_t so it compiles on x64.
> You can look at it here: 
> https://github.com/simendsjo/mysqln/tree/compile-on-recent-dmd
> It hasn't been tested beyond connecting to the database and 
> fetching metadata yet.
> And my repository will go away very soon as I'll rather help 
> with the original library (if Steve Teale comes back) or the 
> one in vibe.

Thanks for sharing the modified code. I was able to compile it 
without any issue and I am able to fetch the meta data. I will be 
testing more to run insert and select queries. But I found a bug 
in the code. If you don't specify the password for your test 
mySQL server then the mysql.d fails. It is always expecting a 
password and on empty password it throws the exception.

file: mysql.d
function: open [line 1415]

I think when it calls _socket.send then it fails.

So far other that this issue, it is working good and if it gets 
stable then certainly I will move forward with a project in D 
Language. I will be using the mongoDB and mySQL so this driver 
will be important for me, in fact for other's too as they 
mentioned in this thread.

One question though, is it thread safe?

Thanks for everyone's effort to make this driver work!
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home