LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2008, 02:58 AM   #1
Galaxy_Stranger
Member
 
Registered: Oct 2003
Distribution: CentOS 6 and Fedora
Posts: 252

Rep: Reputation: 36
C++ and Databases


I've been getting into a lot of database work for school lately - you know, building web sites and stuff. I've been reading up for a project of mine to use C++ APIs to talk to a database server such as MySQL. That works great - and probably best - for that project. But I've got other project ideas that would benefit if my application can manipulate the database directly - I don't want to require the user to install and configure a database server just to run a simple application...kinda like what Microsoft likes to do...

Anyway, if I were to write an application to deal with the database itself without going through a database server - what are the tools I'd need to do that? Or is that even possible? If not, are there any alternatives?
 
Old 08-30-2008, 03:16 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Databases (and the operations on them) are extremely complex; you need the DB server.

There are some lightweight DBs (although the names escape me now).
 
Old 08-30-2008, 03:33 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I don't have an idea what the nature of your project is, but you might look into sqllite.
 
Old 08-30-2008, 04:03 AM   #4
milindlokde
Member
 
Registered: Apr 2007
Location: Mumbai, India
Distribution: Fedora, ubuntu
Posts: 121

Rep: Reputation: 21
You can store your data in files and access it. Similar to how Unix & Perl were/are used to store data in absence of database. You will not be able to create relations between the tables stored in these files. Also you will have deal with data redundancy.

Another option is to use XML as database. I have no experience with XML, but I have read and have seen book titles on XML databases.

You may not be able to directly access the database files unless the are stored in a manner to be able to access it directly. You can find your database under data folder in mysql with the same name as your database, if you like to try to mess with it.
 
Old 08-30-2008, 04:06 AM   #5
Galaxy_Stranger
Member
 
Registered: Oct 2003
Distribution: CentOS 6 and Fedora
Posts: 252

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by jschiwal View Post
I don't have an idea what the nature of your project is, but you might look into sqllite.
AWWW - you beat me to it!

I googled some more to poke around and found someone who came up with some sort of "wrapper" for SQLite. Apparently, there are three: http://www.codeproject.com/KB/database/CppSQLite.aspx
http://www.codeproject.com/KB/databa...ed_db_cpp.aspx
http://www.sqliteplus.com/

Right now, I just want to be able to store player info and scores locally. This is handy for scrollers or even RPG's. The only thing I don't really like about SQLLite is that it doesn't support Foreign Keys.

Screw file i/o. Yeah, sucking the files up is easy but I hate having to parse through everything - it's just more of a mess than I'm willing to put up with.

It looks like SQLLite or some other embedded database is what I was looking for. Thanks for the discussion guys! I THOUGHT it was possible to do it this way.

Last edited by Galaxy_Stranger; 08-30-2008 at 04:10 AM.
 
Old 08-30-2008, 08:21 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
One of the recent Floss Weekly podcasts ( http://twit.tv/floss26 ) had an interview with the creator and lead developer of sqlite.
 
Old 08-30-2008, 06:51 PM   #7
Galaxy_Stranger
Member
 
Registered: Oct 2003
Distribution: CentOS 6 and Fedora
Posts: 252

Original Poster
Rep: Reputation: 36
asdfasdf

Good podcast
 
Old 09-02-2008, 08:53 AM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Generally speaking, I would make two broad-brush statements:
  1. "Don't use C++." If you're working with SQL databases most of your work is going to consist of building text-strings and schlepping them around. Higher-level languages like Perl, PHP, and Ruby will do the same job just as well. (There is a reason why these languages are used so often for database-development.)
  2. "Always practice 'safe SQL.'" In other words, "use a wrapper." Every one of these languages provides a layer of software that can sit between your program and "any database you care to name," specifically so that your program is not hardwired to any particular one. Again, since "most of the work of using an SQL database consists of building strings and schlepping them around," the overhead added by such layers is pragmatically negligible.
When you are designing and building applications of this sort, the "time" that you want to conserve is your own. Not the computer's. You want to build the best possible application, in the least-difficult way, leveraging the greatest amount of existing software.
Quote:
Dictum Ne Agas: "Do Not Do A Thing Already Done."
 
Old 09-02-2008, 03:01 PM   #9
Galaxy_Stranger
Member
 
Registered: Oct 2003
Distribution: CentOS 6 and Fedora
Posts: 252

Original Poster
Rep: Reputation: 36
I have no idea why people think C++ is so hard. There are lots of wrappers and interfaces created for lots of applications all over the place. The syntax is conventional, and if you DO have to reinvent the wheel - you can.

The whole point is that I'm using C++, (this isn't a web interface to a database),and that talking to an independent database server would cut the user off from the data if he was offline or otherwise unable to communicate with the server. SQLite is a great alternative to conventional databases for saving a bit of organized data in the manor of a DBMS without having to run and administer a database server locally.
 
  


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
Databases and Programming JMJ_coder Programming 9 04-08-2008 07:34 AM
sendmail and NIS databases (aliases, mail.aliases) - what kind of databases? cotton213 Linux - Software 0 03-14-2006 05:57 PM
databases varun_33 Linux - Software 2 02-03-2005 12:49 AM
Need to compare 2 databases. Help please! morbid_ru Programming 1 12-08-2003 04:16 PM
Databases frankyboy4 LQ Suggestions & Feedback 1 08-09-2002 01:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:12 AM.

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