LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-29-2021, 01:47 AM   #1
lvm_
Member
 
Registered: Jul 2020
Posts: 925

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
simplest key-value database


Is there a simple key-value database for use in scripts and such? No authentication, no schema, no nothing - just

name <file.db> [get|put] <key>

and in reads/prints value to stdin. Yes, there are hundreds of ways, it can even be done using nothing but grep, but I have a strong aversion to reinventing the wheel and wouldn't mind a decent performance so before I do it using sqlite (which is not key-value at all but happens to be installed) I decided to ask if there is a ready-made solution.
 
Old 07-29-2021, 02:15 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
miller allows you to work with key-value format among others. Generally speaking, there's a ton of tools that work with structured text formats (CSV, XML, JSON, YAML, whatever). And even if grep-dctrl is supposed to be used with Debian control files, I guess it could be repurposed to work with arbitrary data in similar format (sort of generalized RFC 5322).

A more comprehensive solution would be something like Fsdb or GNU Recutils.

Last edited by shruggy; 07-29-2021 at 02:46 AM.
 
Old 07-29-2021, 02:50 AM   #3
lvm_
Member
 
Registered: Jul 2020
Posts: 925

Original Poster
Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
As I said, I'd like to have reasonable performance, and text-based stores usually have horrible update speeds. I found gdbmtool - looks like just what I needed.
 
Old 07-29-2021, 04:47 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
scripts are slow (including bash). How much data do you want to handle at all?
 
Old 07-29-2021, 01:13 PM   #5
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Any database format, text or otherwise, has speed dependent upon the amount of data required (and stored). For a simple key/value pair, even 100+ entries in text format can be accessed in linear format with insignificant delay.

As the database grows then different tools are needed to provide faster (usually indexed) access.

Depending upon your needs you will need to select the best tools and ease of config. Having any form of database server running for a tiny database and infrequent access is a significant waste of cpu time and often config effort.
 
1 members found this post helpful.
Old 07-29-2021, 01:32 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
In the earliest days, these were called "ISAM files" or "VSAM files." They stored and retrieved values based on a single key.

Some languages still directly support indexed files. The Perl language, for instance, can "tie" what appears to be "a hash" to an underlying physical-file representation.

Today, probably the closest technology is SQLite, which is a public domain(!) database system which is entirely based on "a 'database' is a 'single file.'" There is no "server."

>> The only thing that you need to be aware of, when you are updating these files, is the importance of using "transactions." Without this, SQLite will not use "lazy writes." Begin a transaction, insert or change a block of records, then commit.

Last edited by sundialsvcs; 07-29-2021 at 01:34 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strange value assignments variable = value, value?? ostrow30 Programming 2 07-24-2011 07:59 AM
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
difference between value *value and value * value PoleStar Linux - Newbie 1 11-26-2010 03:37 PM
"Enter Key" not working, how to map "Enter Key" functionality to "F9" Key srinihi Linux - Newbie 1 04-03-2009 02:46 PM
Database Programming (database to database transaction) johncsl82 Programming 7 02-02-2007 08:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration