1. Problem wrapping libdbi for Euphoria
- Posted by Jeremy Cowgar <jeremy at cowgar.com> Nov 06, 2006
- 551 views
- Last edited Nov 07, 2006
I need access to both PostgreSQL and MySQL. I was hoping to wrap libdbi. Euphoria makes wrapping C libraries so easy. I am, however, having problems with this one. Here's the error: libdbi.e:191 in function dbi_conn_set_option() A machine-level exception occurred during execution of this statement ... called from libdbi.e:266 Now, like 266 is: VOID = dbi_conn_set_option(conn, "username", "jeremy") Weird thing is, if I change "jeremy" to "john" all works fine. In fact, any 4 letter word works, but any 6 letter word does not work. I have created this same example in C and it works w/o problem, so I doubt it's something in libdbi, but I may be wrong. I have placed my code at: http://jeremy.cowgar.com/files/libdbi.e That contains the wrapper (as it stands now, cannot do anything but connect. It also has the example program at the bottom. I am wondering if anyone has any insight? In short, the code for dbi_conn_set_option is:
atom LDbi_conn_set_option LDbi_conn_set_option = define_c_func(libdbi, "dbi_conn_set_option", {C_POINTER, C_POINTER, C_POINTER}, C_INT) global function dbi_conn_set_option(atom conn, sequence key, sequence value) atom Akey, Avalue integer res Akey = allocate_string(key) Avalue = allocate_string(value) res = c_func(LDbi_conn_set_option, {conn, Akey, Avalue}) free(Akey) free(Avalue) return res end function
Once finished, I will be placing all the code in The Archive so others can benefit as well. Thanks for any help, Jeremy
2. Re: Problem wrapping libdbi for Euphoria
- Posted by Bernie Ryan <xotron at bluefrog.com> Nov 06, 2006
- 531 views
- Last edited Nov 07, 2006
Jeremy Cowgar wrote: > > I need access to both PostgreSQL and MySQL. I was hoping to wrap libdbi. > Euphoria > makes > wrapping C libraries so easy. I am, however, having problems with this one. > Here's the error: > > libdbi.e:191 in function dbi_conn_set_option() > A machine-level exception occurred during execution of this statement > > ... called from libdbi.e:266 > > Now, like 266 is: > > VOID = dbi_conn_set_option(conn, "username", "jeremy") > > Weird thing is, if I change "jeremy" to "john" all works fine. In fact, any > 4 letter word works, > but any 6 letter word does not work. > > I have created this same example in C and it works w/o problem, so I doubt > it's > something > in libdbi, but I may be wrong. > > I have placed my code at: <a > href="http://jeremy.cowgar.com/files/libdbi.e">http://jeremy.cowgar.com/files/libdbi.e</a> > > That contains the wrapper (as it stands now, cannot do anything but connect. > It also has > the example program at the bottom. I am wondering if anyone has any insight? > In short, the > code for dbi_conn_set_option is: > > }}} <eucode> > atom LDbi_conn_set_option > LDbi_conn_set_option = define_c_func(libdbi, "dbi_conn_set_option", > {C_POINTER, C_POINTER, C_POINTER}, C_INT) > global function dbi_conn_set_option(atom conn, sequence key, sequence value) > atom Akey, Avalue > integer res > > Akey = allocate_string(key) > Avalue = allocate_string(value) > res = c_func(LDbi_conn_set_option, {conn, Akey, Avalue}) > free(Akey) > free(Avalue) > > return res > end function > </eucode> {{{ > > Once finished, I will be placing all the code in The Archive so others can > benefit > as well. > > Thanks for any help, > Jeremy: Try using }}} <eucode> atom res' </eucode> {{{ instead of }}} <eucode> integer res </eucode> {{{ Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
3. Re: Problem wrapping libdbi for Euphoria
- Posted by Jeremy Cowgar <jeremy at cowgar.com> Nov 07, 2006
- 497 views
Bernie Ryan wrote: > > Jeremy Cowgar wrote: > > > > I need access to both PostgreSQL and MySQL. I was hoping to wrap libdbi. > > Euphoria > > makes > > wrapping C libraries so easy. I am, however, having problems with this one. > > Here's the error: > > > > libdbi.e:191 in function dbi_conn_set_option() > > A machine-level exception occurred during execution of this statement > > Try using }}} <eucode> atom res' </eucode> {{{ instead of }}} <eucode> integer > res </eucode> {{{ </font> > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > <a > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a> No go ... I saw in the Euphoria docs you could just define a c_proc if you don't care about the result, so I gave that a try. That did not work either, same problem. Jeremy
4. Re: Problem wrapping libdbi for Euphoria
- Posted by cklester <cklester at yahoo.com> Nov 07, 2006
- 533 views
Jeremy Cowgar wrote: > > I need access to both PostgreSQL and MySQL. Have you checked out Jeremy's PostgreSQL wrapper? http://www.rapideuphoria.com/postgressqlwrap1.zip I thought there was a mySQL wrapper, too... -=ck "Programming in a state of Euphoria." http://www.cklester.com/euphoria/
5. Re: Problem wrapping libdbi for Euphoria
- Posted by cklester <cklester at yahoo.com> Nov 07, 2006
- 520 views
cklester wrote: > Jeremy Cowgar wrote: > > I need access to both PostgreSQL and MySQL. > Have you checked out Jeremy's PostgreSQL wrapper? > <a > href="http://www.rapideuphoria.com/postgressqlwrap1.zip">http://www.rapideuphoria.com/postgressqlwrap1.zip</a> > I thought there was a mySQL wrapper, too... Not that libdbi doesn't look great! I'd rather have that... I think. :) -=ck "Programming in a state of Euphoria." http://www.cklester.com/euphoria/
6. Re: Problem wrapping libdbi for Euphoria
- Posted by Jeremy Cowgar <jeremy at cowgar.com> Nov 07, 2006
- 540 views
> cklester wrote: > > Have you checked out Jeremy's PostgreSQL wrapper? > > <a > > href="http://www.rapideuphoria.com/postgressqlwrap1.zip">http://www.rapideuphoria.com/postgressqlwrap1.zip</a> > > I thought there was a mySQL wrapper, too... > > Not that libdbi doesn't look great! I'd rather have that... I think. :) Yes, I did, however, it's for Win32 only, with DLL's and such Sorry, Jeremy. But I'm Linux and Mac user. libdbi will get you a common interface to both. So, I can flip at the drop of a coin. I can also develop using sqlite2, sqlite3, etc... It really is a nice library. Jeremy
7. Re: Problem wrapping libdbi for Euphoria
- Posted by Jonas Temple <jtemple at yhti.net> Nov 07, 2006
- 545 views
Jeremy, Could post the C declaration for the function? That might help find the problem. Jonas Temple http://www.yhti.net/~jktemple