[Gambas-user] Database Results

richard terry rterry at ...1946...
Sun Sep 12 01:44:03 CEST 2010


Hi Tobias,

If you are new to databases, you could choose to go to the best open source 
database from the beginning - postgresql.

There are a wealth of postgresql books and tutorials around on the web. in 
Linux, youve got the pgadmin graphical tool and if you also run windows or a 
virtual machine, and intend to do any serious database programming, then a 
copy of sqlmanager for windows is worth purchasing. http://www.sqlmanager.net/ 
which will solve you hours of grief for complex views and functions. The 
lastest pgadmin also has a rudimentary sql query builder.

There is also a really helpful mail list:

pgsql-novice at ...2059...


which is monitored by Tom Lane one of the postgresql authors/gurus, even the 
simplest questions are answered, or the most complex.

Also, you don't have to use the gambas database gui tools, you can have your 
own routines to connect to the database if you desire, simply establish a 
connection and use that connection for all your work:

Personally I've found it much easier to create all my tables by hand in 
pgadmin or from the command line passing a text file to psql, and just do the 
database acessing from gambas to obtain or insert data, put the data into 
collections, and manipulate and display as needed in the gui.

I never managed to get the gambas gui database connect to link to my database.

One other hint - maybe not that important, but I always backup the database as  
plain and no owner.

Lastly if you've not already got this basic book which, despite its age is not 
really out of date, source this from the command line:

wget http://vectorlinux.osuosl.org/Uelsk8s/gambas-beginner-guide.pdf


Hope this is of some general assistance.

Regards

Richard


> hello mailing list,
> 
> i am absolutely new to databases in general and so to databases in
> gambas, too. i plan to use sqlite3 and in general i am understanding the
> related stuff part by part but it is very confusing with the different
> classes and i think this complicates my learning process.
> but to my questions now. i want to make a database table just in memory
> to get me a bit closer to this all:
> 
> hConnection = NEW Connection
> hConnection.Type = "sqlite3"
> hConnection.Open()
> hTable = hConnection.Tables.Add("test")
> hTable.Fields.Add("id", db.Serial)
> hTable.Fields.Add("name", db.String)
> hTable.PrimaryKey = ["id"]
> hTable.Update()
> hResult = hConnection.Create("test")
> 
> and in the following i want to add three names to the database and then
> hResult.Update() them, but how do i create more records than one? (i
> used hResult["name"] = "tobi" to create the first, this works)
> 
> the next question.
> i got a result from a database with some records predefined (fields are
> id (serial) and name (string)):
> 
> hResult = hConnection.Exec("select * from test")
> 
> in a for loop i go through all the records by doing:
> 
> FOR iCount = 0 TO hResult.Count - 1 STEP 1
>   hResult.MoveTo(iCount)
>   FOR EACH hField IN hResult.Fields
>     TextArea1.Insert(hResult[hField.Name])
>   NEXT

>   TextArea1.Insert("\n")
>  NEXT
> 
> which works also fine but i really don't like the hResult.MoveTo() part
> of this code, isn't there any way to handle this result simply as an
> array? this would solve both problems and i could do database stuff with
> ease?
> 
> regards, tobi
> 
> ---------------------------------------------------------------------------
> --- Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 




More information about the User mailing list