Solved

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

Posted on 2013-01-10
2
419 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 24

Accepted Solution

by:
chaau earned 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now