Python integration with jBase

385 views
Skip to first unread message

Guru Prasanna Nagarajan

unread,
Jun 12, 2007, 7:33:45 AM6/12/07
to Jbase Groups
Hi,
 
I would like to use Python to connect to jbase database and also be able to call python functions from jbase (somethin like CALLJ or CALLC?). Is it possible?
 
In jbase website I see there was an attempt but I am unable to download the component. If any one already have it, could you share it with me?
 
 
 
I would like this more for personal interest. I donot have any particular requirement now (as of now).
 
Thanks
Guru

Daniel Klein

unread,
Jun 12, 2007, 11:56:42 AM6/12/07
to jB...@googlegroups.com
I'm the one who wrote the Jukebox stuff, but that was 6 years ago. It basically works by creating a pipe to a jBASE basic program and delegates all of its work as server-side operations. I wrote it just to see that I could do it cos anything is better than java :-)

I was in the middle of writing a socket interface but Jim Idle sold JBCSOCKS and now you have to spend lots of dosh to get it, so I never completed the socket interface.

I can see about getting it working again but I suspect that it would have to be 'modernized' in order to work with recent versions of jBASE and Python. What versions of jBASE and Python are you using?

There is nothing out there that I know of that is a Python equivalent to CALLJ. What sort of Python functions do you want to 'call' ?

Dan

Jim Idle

unread,
Jun 12, 2007, 12:13:23 PM6/12/07
to jB...@googlegroups.com

The problem with python is the stupid indent syntax, which reveals it was designed by someone who knows nothing about language design, despite what is said about “human readable” and “forces indent levels”, which is the equivalent of saying that it is amazing that a pedestrian crossing was marked out just where people are crossing the road.

 

Other than that it isn’t any worse than any of the other ‘scripting’ languages that have come up over the years and better than some of them. I think that by far the easiest and best thing to do would be to hook the python interpreter into a jBASE aware DLL/.so and then you can just call python scripts directly from jBC.  Looks like a couple of days work from their documentation.

 

Jim

Daniel Klein

unread,
Jun 12, 2007, 1:24:28 PM6/12/07
to jB...@googlegroups.com
I'm not much into Python anymore, but I'll help out the OP if I can.

At the time I was into it, the reason I (and I presume other advocates of the language) liked the indent syntax was to obviate the need for line and block delimiters/terminators as it greatly reduces the size of your code. Pretty much all of the Python editors/IDEs were smart enough to indent/dedent as needed.

I happen to be partial to Smalltalk, which is a pure OO language, unlike that other language I won't mention that starts with ja and ends with va ;-)

Dan

Guru Prasanna Nagarajan

unread,
Jun 13, 2007, 9:57:14 AM6/13/07
to Jbase Groups
Hi Daniel,
 
I did see your name in more than one 'Python' discussion forum dating back to 2001.... I started with Python, because I wanted to use ANTLR (python) , also be able to do prototyping (faster).. Also python takes lesser time for learning.
 
My reason for looking for Python and jbase integration is because jbase is the database I am comfortable with, have easy access to. So doing my education around jbase would mean I can relate to my 'own' examples better....after which i will go back to ANTLR...
 
If you have the original code, I could try to 'Modernize' it. 
 
As far as similar to CALLJ, just to add another extension to jbase for 'future' use. I also thought it might easier to use python with jbase as python is dynamically typed (unlike java or c - which are statically type), which might suit with jbase for passing values between functions (for example - while using socket functions or other services available in python.). Other function on interest would be xml package(mindom) in python.
 
 
Thanks
Guru

Jim Idle

unread,
Jun 13, 2007, 11:26:59 AM6/13/07
to jB...@googlegroups.com

Guru,

 

You could always use the C output (http://www.antlr.org/wiki/display/ANTLR3/ANTLR3+Code+Generation+-+C) from ANTLR 3 as the guy the wrote that is most handsome and most exceptionally clever and made sure it works with jBASE. I have a lot of respect for that man K

 

In C you have access to the jBASE internal variable via some easy to use macros – passing data in to and out of ATNLR generated C parsers is easy, as is writing ANLTR actions that use jBASE macros. In fact, this is how jQL in jBASE 4.1 is parsed. I also use ANTLR, but (version 3 this time) for the Query parser in Caché, though it is completely different (and a lot easier) in ANTLR 3 – that is one of the reasons I write the C output for ANTLR 3.

 

The Python output for ANTLR is really intended for situations where you already have Python as your application. Python isn’t as fast as C and in order to use the Python output with jBASE you would need to start the Python interpreter etc. On the other hand a C function to call you C parser is trivial and well supported in jBASE. Also, unless you don’t know Java, the Java output from ANTLR would work pretty easily too.

 

But, as I said, adding a C function to spark up the Python interpreter looks pretty easy to me.

 

I have a complete parser for jBC/Pick BASIC in ANTLR 3 – I am currently debating whether to make this public domain or not (there are probably wrinkles in it yet) as I may yet use it for products of my own.

 

Jim

 

From: jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of Guru Prasanna Nagarajan
Sent: Wednesday, June 13, 2007 6:57 AM
To: Jbase Groups
Subject: Re: Python integration with jBase

 

Hi Daniel,



</div

Guru Prasanna

unread,
Jun 17, 2007, 4:42:38 PM6/17/07
to jB...@googlegroups.com

Jim,

 

Thanks for that Link. I will do further reading and on doubts now I know which ‘clever’ man to get hold of!!.

 

Of course I would look out for Pick Basic ANTLR 3, if you are going to make put it in Public domain!!

 

guru

 


Gary Calvin

unread,
Jun 17, 2007, 5:51:25 PM6/17/07
to jB...@googlegroups.com
On 6/13/07, Jim Idle <ji...@temporal-wave.com> wrote:

I have a complete parser for jBC/Pick BASIC in ANTLR 3 – I am currently debating whether to make this public domain or not (there are probably wrinkles in it yet) as I may yet use it for products of my own.


Other possibilities are to make it available under a BSD-style license, or GPL. BSD is close to public domain, in that it makes the work available for anyone to use with no restrictions, but it preserves your Copyright in the work. GPL requires that "derivative works" also be licensed under the GPL. However, if you don't accept patches from the community, or if you require that Copyright in any patches be assigned to you, then you are free to sell non-GPL licenses to customers who don't want the GPL restrictions. This is what MySQL, TrollTech, and many other projects do. It's a good way to get the code out there and get feedback and bug reports, without sacrificing future commercial possibilities.

-Gary-


Daniel Klein

unread,
Jun 21, 2007, 3:17:22 PM6/21/07
to jB...@googlegroups.com
Guru,

I took the time to add a bit of 'modernization' to both the client and server side components. You currently need Python 2.5 (because it now uses the 'subprocess' module instead of 'popen2') and jBASE 4.1.5 to run things (I think it will run ok with jBASE 4.1.4).

The 'readme.txt' file contains installation and 'getting started' instructions as well as some other useful notes.

I really don't intend to do much more with it as I originally did it just to see that I could :-)  However, if you find something you want me to look into then please email me privately at my gmail address, or the address in the 'readme'.

Good luck and have fun with it...

Dan
jukebox.zip

Guru Prasanna

unread,
Jun 28, 2007, 1:29:56 PM6/28/07
to jB...@googlegroups.com

Daniel,

 

Thanks for the attachment.

 

Rgds

Guru

 


From: jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of Daniel Klein
Sent: Friday, June 22, 2007 12:47 AM
To: jB...@googlegroups.com
Subject: Re: Python integration with jBase

 

Guru,

Reply all
Reply to author
Forward
0 new messages