[pygr-notify] Issue 71 in pygr: Support write operations to SQL databases
codesite-noreply at google.com
codesite-noreply at google.com
Thu May 7 00:09:46 PDT 2009
Comment #4 on issue 71 by jqian.ubc: Support write operations to SQL
databases
http://code.google.com/p/pygr/issues/detail?id=71
Hi Chris,
I tested the four basic write operations (see below). It works great.
Jenny
*original table
mysql> select * from run_data_pe;
+----+---------+---------+---------+
| id | total | U0 | UM |
+----+---------+---------+---------+
| 1 | 5995633 | 1684314 | 1132511 |
| 2 | 6276157 | 2033901 | 1151109 |
| 3 | 6147752 | 1687606 | 1282933 |
+----+---------+---------+---------+
*test code
>>> conn = sqlgraph.DBServerInfo(user='root')
>>> testTB = sqlgraph.SQLTable('test.run_data_pe', serverInfo=conn,
>>> writeable=True)
# create a new row
>>> testTB.new(id=4, total=6073153, U0=1924043, UM=1137506)
<pygr.classutil.TupleORW_test.run_data_pe object at 0x1016af6d0>
mysql> select * from run_data_pe;
+----+---------+---------+---------+
| id | total | U0 | UM |
+----+---------+---------+---------+
| 1 | 5995633 | 1684314 | 1132511 |
| 2 | 6276157 | 2033901 | 1151109 |
| 3 | 6147752 | 1687606 | 1282933 |
| 4 | 6073153 | 1924043 | 1137506 |
+----+---------+---------+---------+
# change the ID of an existing row
>>> run = testTB[1]
>>> testTB[5] = run
mysql> select * from run_data_pe;
+----+---------+---------+---------+
| id | total | U0 | UM |
+----+---------+---------+---------+
| 5 | 5995633 | 1684314 | 1132511 |
| 2 | 6276157 | 2033901 | 1151109 |
| 3 | 6147752 | 1687606 | 1282933 |
| 4 | 6073153 | 1924043 | 1137506 |
+----+---------+---------+---------+
# change the value of an existing row
>>> run.UM = 1
mysql> select * from run_data_pe;
+----+---------+---------+---------+
| id | total | U0 | UM |
+----+---------+---------+---------+
| 5 | 5995633 | 1684314 | 1 |
| 2 | 6276157 | 2033901 | 1151109 |
| 3 | 6147752 | 1687606 | 1282933 |
| 4 | 6073153 | 1924043 | 1137506 |
+----+---------+---------+---------+
# delete an existing row
>>> del testTB[5]
mysql> select * from run_data_pe;
+----+---------+---------+---------+
| id | total | U0 | UM |
+----+---------+---------+---------+
| 2 | 6276157 | 2033901 | 1151109 |
| 3 | 6147752 | 1687606 | 1282933 |
| 4 | 6073153 | 1924043 | 1137506 |
+----+---------+---------+---------+
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
More information about the pygr-notify
mailing list