OK, how does this editor thing work...
The editor can be reached by choosing File->Table Info. This will
pop up a list box that displays all of the tables and views that
the user has access to. Clicking the button labeled "Edit"
or double clicking the table name will bring up the edit view
of the table. This view has a grid of the table and always has a "last"
row of fields that contain a single '*' character. Beneath the
grid is two rows of navigation tools. If the selected table
name is actually a view, then the editing buttons will be
disabled.
select * from table where
When the "Use Filter" button is clicked the contents of
the resulting string is executed and the results displayed
in the grid.
Suppose we are editing a table named "bills" then if the
text field contained "category='Medical'" (no double quotes
in the actual entry) and the Use Filter
button is clicked then the sql statement:
select * from bills where category='Medical'
would be executed and the rows would be displayed.
If the text field contained "true" (no quotes) then the
sql statment:
select * from bills where true
would be executed and ALL of the rows would be displayed.
This would not be a wise thing to do if the table had
millions of rows. However, we can limit the number of
rows displayed by placing:
true limit 1000
in the text field. The resulting statement would be
select * from bills where true limit 1000
This statement would retrieve 1000 rows from the
table.
update foo set "c1"='b1',"c2"='b2',"c3"='b3'
where "c1"='a1' and "c2"='a2' and "c3"='a3'
An INSERT command looks like
insert into foo values('b1,'b2','b3')
The DELETE command would become
delete from foo where "c1"='b1' and "c2"='b2' and "c3"='b3'
Note that the contents of the cells are quoted by the
program. This needs a bit of tweeking to handle
the cases of the special values None,DEFAULT,BYTEA and LOBJ.
If the strings None, DEFAULT,BYTEA or LOBJ are found in the
buffer (case is important). The update and insert
commands will be tweeked. Suppose in the above
we have b3 containing None and b2 contains DEFAULT
and a1 contains None. ( Psycopg will transform None
into NULL.)
Then the above three commands will become
update foo set "c1"='b1', "c2"=DEFAULT, "c3"=NULL
where c1 is NULL and c2='a2' and c3='a3'
insert into foo values ('b1',DEFAULT,NULL)
delete from foo where c1 is NULL and "c2"='a2' and "c3"='a3'
If a BYTEA or LOBJ is found in the Buffer then the user will be asked
to pick a file that will become the contents of the field or in
the case of LOBJ the contents will be the oid of the large
object. This
will make importing images into the database every easy to
do. Note If you change a field containing a large object oid you will "lose" the previous contents and will need to clean up the pg_largeobject table.
curs.execute("sqlstringwithplaceholders", arglist)
Last update July 17,2006