One thing to know in Lua is that these 4 are equivalent:
GameInfo.Buildings.BUILDING_TEMPLE.Cost
GameInfo["Buildings"].BUILDING_TEMPLE.Cost
GameInfo["Buildings"]["BUILDING_TEMPLE"]["Cost"]
local mytable = "Buildings"
GameInfo[mytable].BUILDING_TEMPLE.Cost
All of these evaluate to a single value, the Cost of the temple building. Lua is weird in that you can have integers or text (or almost anything) as keys to tables, and GameInfo lets you use either the Type field ("BUILDING_TEMPLE") or the ID (an integer) in that second index position. So, let's say the ID for temple is 17 (I just made that up). You could then get the same value with:
GameInfo.Buildings[17].Cost
Note that GameInfo.Buildings.17.Cost is not correct because it is really shorthand for GameInfo.Buildings["17"].Cost
I could also get the whole table for Temple like this:
local temple = GameInfo.Buildings.BUILDING_TEMPLE
temple is now a table; we can get the Cost of temple now using temple.Cost
Putting "()" after something makes Lua try to interpret it as a function. This won't work unless someone has set it up to work as a function (using metatables, but you don't need to worry about how to do that). Firaxus has made GameInfo work so that GameInfo.Buildings() acts as an iterator function. You can do this on any table added by Firaxis or you (as an OnModActivated table). Basically, you are only ever going to see this as part of a "for" loop when you want to iterate through a table and get each row to process in your loop.
So all of my answers above are about getting values from tables with Lua (your OP).
But now you are asking about adding values to Database tables via Lua. You definitely should not be trying to change tables like Buildings (or any new tables that you add by OnModActivated) using Lua. It's not a stupid question -- I was asking the same thing 9 months ago -- but it is a totally misguided question. Those tables added via XML or SQL are "fixed" and
define what Buildings are in a sort of immutable way. Don't even think of trying to change the DB values. Now, there are many Lua functions that can change things on the fly during game session, and these are the object functions you find at the
wiki for units, plots, and so on. You can change a lot this way but not everything. In general, your code will need to "remember" your adjustment from the initial table value, and apply that value during game init as the game is loaded (or else apply it each turn based on some info that you can calculate from Lua). The advanced mods do this kind of thing all the time, but it takes a bit of effort to learn how. But just forget about changing the actual DB value
during a game by Lua -- it doesn't work that way.