[Twisted-Python] Question about using the adbapi
Albert Brandl
albert.brandl at weiermayer.com
Tue May 10 03:50:30 EDT 2011
On Mon, May 09, 2011 at 02:15:04PM +0300, Pandelis Theodosiou wrote:
> a) keep the last (longitude, latitude) pair for every receiver stored
> in your script, too, besides the db. When a new pair of values
> arrives, compare it with the current and only if it is different, send
> the "INSERT" query to the database.
This will only work if I can guarantee that the database query is
finished before the next (longitude, latitude) pair arrives. Otherwise,
I'll lose the previous pair. Storing a list of (longitude, latitude)
pairs won't work either: the database queries are executed in separate
threads, and I can't control the order in which they will finish. So
I have no correspondence between the query result and a (longitude,
latitude) pair.
For GPS data, this might not be an issue, since a new position arrives
only about once a second. But other data (e.g. the current speed) are
sent every ten ms or so. For these, I have to make sure that the current
data corresponds to the query result.
> b) When a new pair of values arrives, send a query (or stored
> procedure) that tells the database to check and "INSERT" only if the
> pair is different that the latest.
That is an interesting option, since it moves the responsibility from
the Twisted server to the database.
Thanks & best regards,
Albert
--
Albert Brandl
Weiermayer Solutions GmbH | Abteistraße 12, A-4813 Altmünster
phone: +43 (0) 720 70 30 14 | fax: +43 (0) 7612 20 3 56
web: http://www.weiermayer.com
More information about the Twisted-Python
mailing list