Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick file-based (non server-based) SQL database usage.

Status
Not open for further replies.

VuurSnikkel

Programmer
Sep 8, 2003
16
NL
Hi there ppl,


First things first: I'm becoming increasingly frustrated by the "handy" ways in which Delphi users are supposed to access their database. I'm currently writing a Win32 program that needs to store some information on a per project basis (each project consists of one or more files and I want some of these files to contain tables and records, hence, a database).

I've been doing quite a lot of web-based DB-related work using PHP and MySQL and I don't mind using something like MySQL server in such a case, but this application needs to be stand-alone, so I don't need some server running in the background when a user is working with the program.

(The file format for the files that store the database don't need to be fancy; plain text will do. Something like MySQL's structure and data dump for example or some XML file. These can be used to create the whole database on load.)

Let's illustrate what I have in mind by a few lines of pseudo-code:

...
OpenDatabaseFile('MyDatabase.Ext');
//Manipulate the database using SQL queries...
SaveDatabaseFile('MyDatabase.Ext');
...

There. That's it. Sounds pretty clear and logical to me, but I haven't got a clue about how to accomplish this, because whenever I try to find some examples of this using Google, different Dephi forums, Torry's Delphi pages etc., I end up with documents about ODBC, MSJet, Interbase, BDE, ADO and other client/server types of databases. <FRUSTRATION>I don't need all of that, I'm writing a single-user, single-machine application that needs some form of file-based database access. No servers. No middleware. No connections with programs running in the background. No overhead. Is this really so uncommon?</FRUSTRATION>.

I've come to the point that I thought about writing my own database engine for this application, but I simply can't believe that there isn't a viable alternative to using servers and/or writing the whole engine myself.

I'm really getting tired of all the overhead involved with accessing a database in Delphi and any help would be greatly appreciated. Thanks in advance.


GRTZ,

(Sn)Ik.
 
Hello again,


I've found something that might do the trick. In case other people are also looking for SQL database access using plain text-files for storage:

TjanSQL 1.1 (2-April-2002 size: 379kb
TjanSQL is a single user relational Database engine implemented as a Delphi object using plain text files with semi-colon separated data for data storage.


GRTZ,

(Sn)Ik.
 
Very simple option. Use TClientDataSet.SaveToFile. Saves that dataset as an XML file. You can even included nested tables.

Borland have given this a jargon name, MyDB or something.

Good luck
Simon
 
Hi...


I've just started using TClientDataSet and it does indeed look promising and is exactly what I had in mind as far as I can tell at this point. Thanks a lot.


GRTZ,

(Sn)Ik.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top