Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

timestamp before select after an application has successfully done stuff with a select

Posted on 2013-01-10
2
Medium Priority
?
467 Views
Last Modified: 2013-01-12
I have a python script which is querying an sql-database. it does some stuff with the query, then puts a timestamp on the sql-database, so it only has to query the stuff that's happened after that timestamp.

The process takes a few minutes, so putting the timestamp at the end of the process means it might miss stuff that happened after the select query, but before it'd finished doing stuff.

I tried beginning a transaction, making a timestamp, doing the query, then committing the transaction, but it wouldn't give me the results of the select query until after i'd committed (defeating the whole point).

What is a good way of doing this?
0
Comment
Question by:rdun25
2 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 400 total points
ID: 38765698
If you can modify the table you are working with, you need to create a column called "Working", or similar. Then at the beginning of the process update the column for all unprocessed records to TRUE. Then select all records with Working=TRUE. After you process each records update the timestamp and Working=FALSE using a single UPDATE.

If you do not have access to the database, then first update the timestamp to a certain value (say your DOB), then select all records with this value. While processing each record update the record with the current time. This second method is less preferable, as it may break some reports that use this timestamp value for reporting
0
 

Author Closing Comment

by:rdun25
ID: 38770710
Thank you so much. This is going to work way better then my plan. You've prevented another problem which would have come up later as well.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question