REALbasic Database Examples

Bearboat Software Logo
Bearboat Software

Software Downloads

DBCreator allows you to create empty databases with the tables and fields that you specify

DBCreator DMG
DBCreator ZIP

DBHandler allows you to Enter, Delete, Export, Modify etc data in these databases

DBHandler DMG
DBHandler ZIP

DBCreator and DBHandler

Programs with Source Code Available: Download Links in Left Panel

I have made available for download two simple programs. These downloads are both less than 400 KB.

For people trying to learn the REALBasic code that allows the creation and use of databases, these examples might be useful. The code is freely available. I stumbled a lot when I started with databases in REALBasic and this site is just an attempt to give others a bit of a jump start.

I have the need, for a programming project that I am working on, to use the REALBasic database. This requirement is actually a minor part of the project, but I thought it reasonable to try and learn enough about REALBasic SQL database to be able to use it.

I have used 4D (a database program) for many years, but I had no previous experience with SQL, and my REALbasic is rusty. To warm up, I decided to create a very elementary database program just to become familiar with the environment.

I decided early on to do everything in code. There were tools in REALbasic to create a database rapidly, but I did not like the smell of them. There is a database controller etc. My own experience is that such “magical” tools may get you started quickly but tend to lead you into cul de sacs. Many of the texts that I could find on “introduction to REALBasic databases” tend to use these tools, which for me was a source of frustration as that is not the way I wanted to go.

I was bootstrapping my understanding, and I wished that I had had more examples of REALBasic database code so as to get myself started. So I have decided to release the code that I came up with on the chance that it might be useful to some other poor soul trying to understand how to use a simple database in REALbasic. I hope it is more helpful than confusing. Any code contained here can be used without restriction.

I was using REALBasic on the Mac 2006R4 when this code was written. I used the REALBasicSQL database that comes with REALBasic, which is based on SQLite.

Two programs are provided with the code freely available for review.

The first is called DBCreator and this program has a simple interface that allows you to create a database file. It is not a very finished program, but it does contain the basic code that is needed to create a database. It outputs “empty” REALBasicSQL databases with the tables and fields that the user specifies.

DBHandler is the second program. It is capable of viewing an existing database and modifying, deleting and entering data into a database.

Neither of these programs is polished in any way. I just offer them up to provide others with another resource to use when trying to understand the database side of REALBasic. You might be able to steal bits of code or ideas that are helpful in trying to get started with databases.

DBCreator goes out of its way to use XML in saving the database designs that are being worked on. I did this because I was also interested in learning XML in the context of REALBasic.

DBCreator can open and save XML files that represent the user’s table/field designs. These end up in a DatabaseDesigns folder. When you are finished, you use the Save SQL Database button to produce the data file that can actually be used and this ends up in a EmptySQLDatabases folder. These files can in turn be opened by DBHandler, which can add data to them. Other programs that open SQL databases could also open these files. DBHandler can also open other SQL databases beyond the empty shells created by DBCreator.

SQLite databases are just one flavor of SQL databases. DBCreator allows you to specify characteristics that SQLite will ignore (Example VarChar(20) – SQLite pays no attention to the (20) part of the specification).

Email me with any comments