db shell
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > db shell




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    db shell  
Ian Zimmerman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM


Hi, I am looking for a program to interactively retrieve and store
records in Berkeley DB files (actually, a similar program for an
equivalent database package like gdbm would do, as well; I just like DB
because of its wide and well documented API).

I have in mind something like the following hypothetical transcript.

$ bdbshell foo.db
BDB> get "foo"
BDB: foo.db: key "foo" not found
BDB> set "foo" "bar"
BDB> get "foo"
bar
BDB> set_multiline "foo"
bar
baz
^C
BDB> get "foo"
bar
baz

BDB>

You get the idea.

I think I need it because I want to access DB files from an interpreter
that cannot be extended with C code, but can communicate with spawned
subprocesses.  If you have another suggestion how to achieve this,
I am listening.

I could also use sqlite but there will be no joins, so any relational
features are overkill.

Thanks.  I have googled, without apparent success.

--
"It's not true or not."  A reality show producer (real quote)





[ Post a follow-up to this message ]



    Re: db shell  
Keith Bostic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM

Ian Zimmerman <itz@buug.org> wrote in message news:<878yeg3xql.fsf@buug.org>
..

> Hi, I am looking for a program to interactively retrieve and store
> records in Berkeley DB files (actually, a similar program for an
> equivalent database package like gdbm would do, as well; I just
> like DB because of its wide and well documented API).
>
> I have in mind something like the following hypothetical transcript.
>
> $ bdbshell foo.db
> BDB> get "foo"
> BDB: foo.db: key "foo" not found
> BDB> set "foo" "bar"
> BDB> get "foo"
> bar
> BDB> set_multiline "foo"
> bar
> baz
> ^C
> BDB> get "foo"
> bar
> baz
>
> BDB>
>
> You get the idea.

The are Berkeley DB APIs for most popular interpreted languages:
Perl, Tcl, Python and so on.  Why not use one of those?  You can
do almost exactly what you're describing in Tcl:

set e [berkdb env -home TESTDIR -create -txn -recover]
set d [berkdb open -create -btree -env $e -auto_commit a]
set t [$e txn]
$d put -txn $t aaa data
$d put -txn $t aab data
$d put -txn $t aac data
$d put -txn $t aad data
$t commit
$d close
$e close

Regards,
--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic                    bostic@sleepycat.com
Sleepycat Software Inc.         keithbosticim (ymsgid)
118 Tower Rd.                   +1-781-259-3139
Lincoln, MA 01773               http://www.sleepycat.com





[ Post a follow-up to this message ]



    Re: db shell  
Ian Zimmerman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM


Ian> $ bdbshell foo.db
Ian> BDB> get "foo"
Ian> BDB: foo.db: key "foo" not found
Ian> BDB> set "foo" "bar"
Ian> BDB> get "foo"
Ian> bar
Ian> BDB> set_multiline "foo"
Ian> bar
Ian> baz
Ian> ^C
Ian> BDB> get "foo"
Ian> bar
Ian> baz
Ian>
Ian> BDB>

Keith> The are Berkeley DB APIs for most popular interpreted languages:
Keith> Perl, Tcl, Python and so on.  Why not use one of those?

The idea of generating PERL code reminds me of seeing _Quills_ last
weekend :-)

Tcl might be another matter.  As for Python, that was actually my first
reaction, but I haven't found a DB binding.  Can you point me to one?

Thanks.

--
"It's not true or not."  A reality show producer (real quote)





[ Post a follow-up to this message ]



    Re: db shell  
William Park


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM

Ian Zimmerman <itz@buug.org> wrote:
>
> Ian> $ bdbshell foo.db
> Ian> BDB> get "foo"
> Ian> BDB: foo.db: key "foo" not found
> Ian> BDB> set "foo" "bar"
> Ian> BDB> get "foo"
> Ian> bar
> Ian> BDB> set_multiline "foo"
> Ian> bar
> Ian> baz
> Ian> ^C
> Ian> BDB> get "foo"
> Ian> bar
> Ian> baz
> Ian>
> Ian> BDB>
>
> Keith> The are Berkeley DB APIs for most popular interpreted languages:
> Keith> Perl, Tcl, Python and so on.  Why not use one of those?
>
> The idea of generating PERL code reminds me of seeing _Quills_ last
> weekend :-)
>
> Tcl might be another matter.  As for Python, that was actually my first
> reaction, but I haven't found a DB binding.  Can you point me to one?

Ref:
http://freshmeat.net/projects/bashdiff/
http://home.eol.ca/~parkw/index.html#bash

It has GDBM and SQLite.  And, I'm working on PostgreSQL, now.  Regarding
your example,
gdbm boo.db foo
gdbm boo.db foo bar		--> store
gdbm boo.db foo
gdbm boo.db foo 'bar	--> store string
baz'
gdbm boo.db foo

Yours truly,
--
William Park, Open Geometry Consulting, <opengeometry@yahoo.ca>
No, I will not fix your computer!  I'll reformat your harddisk, though.





[ Post a follow-up to this message ]



    Re: db shell  
Keith Bostic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM

Ian Zimmerman <itz@buug.org> wrote in message news:<87vfhj6jwt.fsf@buug.org>
..

> Tcl might be another matter.  As for Python, that was actually my first
> reaction, but I haven't found a DB binding.  Can you point me to one?

The Tcl and PERL bindings are included in the Berkeley DB distribution.

PyBSDDB is a set of Python wrappers for the Berkeley DB library,
allowing the use of most of the features of DB from the Python language.
The DB objects can be used in a variety of ways, from simple persistent
dictionaries all the way up to full transaction-protected databases. The
Python wrappers allow you to store Python string objects of any length,
keyed either by strings or integers depending on the database access
method.  With the use of another module in the package standard
shelve-like functionality is provided allowing you to store any pickable
Python object, allowing you to easily create an Object Database.

More information is available at:

http://pybsddb.sourceforge.net/

Other sites that have provided useful Python information and interfaces
include:

http://www.python.org

but we believe that the Sourceforge site is currently the most up-to-date.

Regards,
--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic                    bostic@sleepycat.com
Sleepycat Software Inc.         keithbosticim (ymsgid)
118 Tower Rd.                   +1-781-259-3139
Lincoln, MA 01773               http://www.sleepycat.com





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:24 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register