1. Problem wrapping libdbi for Euphoria

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

new topic     » topic index » view message » categorize

2. Re: Problem wrapping libdbi for Euphoria

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Problem wrapping libdbi for Euphoria

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 sad ... 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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Problem wrapping libdbi for Euphoria

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/

new topic     » goto parent     » topic index » view message » categorize

5. Re: Problem wrapping libdbi for Euphoria

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/

new topic     » goto parent     » topic index » view message » categorize

6. Re: Problem wrapping libdbi for Euphoria

> 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 sad 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

new topic     » goto parent     » topic index » view message » categorize

7. Re: Problem wrapping libdbi for Euphoria

Jeremy,

Could post the C declaration for the function?  That might help find the
problem.

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu