help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] databases for bash and other data structures


From: Jesse Molina
Subject: Re: [Help-bash] databases for bash and other data structures
Date: Tue, 12 Mar 2013 23:14:48 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 SeaMonkey/2.16


The current script that I'm working with is for mostly educational purposes, so efficiency be dammed. It would be a lot better if I rewrote it in python, but that's not nearly as challenging.

Also I did find this;

Light sql like database written in Bash
http://snipplr.com/view/50558/

I've used both mysql and sqlite in bash scripts a couple of times, so I'm familiar with that. I'm mostly looking at alternatives within bash itself, or something smaller than sqlite.



Chris Down wrote:
Hi Jesse,

On 2013-03-12 22:19, Jesse Molina wrote:
I have a huge complicated script that now needs a database.

My needs are very modest.  A comma delineated file would probably be
fine, but this script is going to be both reading and writing to
it's tables.  It's mostly when I have to start writing my data out
that stuff gets ugly.

It sounds like you're already aware, but just in case: you don't want to use
bash to do this as you'll get huge performance drop off when you're not
appending.

sqlite is perfect for this, but I wanted to ask if there are any
other tiny database/data structure apps which are often used with
bash, or examples of implementing complicated data structures with
bash.

Most people don't use databases with bash, but as long as your database
application accepts input sensibly from STDIN (ie. it has reliable escaping
methods in its command line client, and if you have untrusted input, there are
more things that you need to verify as well), then you should be fine.

Ideally you'd have a client that respects argument quoting properly. I know of a
few who take commands as a single argument and then eval it. That's almost
definitely a bad idea in a script. You want something that properly escapes
based upon which argument is being read, and internally escapes appropriately.

I don't know off the top of my head which databases do/do not have a client like
that. Hopefully there are some out there (or you can, of course, write a wrapper
for your database in some other language that takes command line arguments, and
escapes them appropriately based upon what each argument represents).

Best of luck with your script.

Chris


--
# Jesse Molina
# Mail = address@hidden
# Cell = 1-602-323-7608





reply via email to

[Prev in Thread] Current Thread [Next in Thread]