Say I have a simple table that contains username, firstname, lastname.
How do I express this in berkeley Db?
I’m currently using bsddb as the interface.
Cheers.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have to pick one “column” as the key (must be unique; I imagine that would be “username” in your case) — the only way searches will ever possibly happen. The other columns can be made to be the single string value of that key by any way you like, from pickling to simple joining with a character that’s guaranteed to never occur in any of the columns, such as `\0′ for many kind of “readable text strings”.
If you need to be able to search by different keys you’ll need other, supplementary and separate bsddb databases set up as “indices” into your main table — it’s lots of work, and there’s lots of literature on the subject. (Alternatively, you move to a higher-abstraction technology, such as sqlite, which handles the indexing neatly on your behalf;-).