Re: SQL queries and their results



On Mon, 2010-04-26 at 22:38 -0400, Scott Nettleton wrote:
First of all, let me start by saying that I love Glom. I've tried a lot
of other database softwares, but haven't found anything approaching the
ease of use and versatility that Glom offers.

Unfortunately, its documentation is rather sparse. I'm familiar with SQL
databases, and with the python language and syntax; but I'm accustomed
to accessing SQL through PHP scripts.

In PHP, if I wanted to perform and advanced database query, I would
write something like:
$query="SELECT * FROM tblCustomers WHERE fldId = $thisId AND
fldFrequentCustomer = TRUE";

If you use Find (from the Mode menu), and enter values in two fields,
that will do an AND search.

However, I guess you want to do something in a button script.

$result=mysql_query($query);
while ($row=mysql_fetch_assoc($result)) {
      echo $row["fldFirstName"]." ".$row["fldLastName"]."<br>";
}

It's useful to me because I can directly access the database without
having to set up a relationship between tables in a GUI, and because I
can specify the individual fields by name (fldFirstName, fldId, etc).
The closest thing I've found to documentation on the subject is at the
website:
http://library.gnome.org/users/glom/unstable/sec-calculated-fields.html.en
The bottom of the page shows an example utilizing an SQL query, but I'm
not familiar with the functions used to access the information.

This is the pygda API. I must try to get its documentation online.
Sorry.

In the meantime you might have some luck with running this on the
command line:
pydoc -w gda
though the result is quite awful.

It's based on the C libgda API, which has better documentation:
http://library.gnome.org/devel/libgda/stable/

 The only
function I see that accomplishes direct data access is
"data_model.get_value_at(col_index, row_index).get()." The problem is,
the data must be specified by row index (not too big a problem, but also
by a numerical column index (rather than the field name). This seems a
bit convoluted to me, and I expect that there's a simpler way to
accomplish it, but I haven't been able to find it in online
documentation or even an Ubuntu forum post.

Yes, I would prefer to use a column name, but you do know the column
number because you wrote the SQL query, so it is doable, right?

I guess the idea is that it would affect performance to do an additional
lookup via the field name.

But if this is important, I can try to add the feature to libda and
pygda for use in a future version of GLom.



-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]