I would like python to check my sql table (column name date_loaded) if it is populated with current date in format yyyymmdd. if it is then continue my process else send the user and email to to check the table and end the process
Python code to check SQL table for current date
Python code to check SQL table for current date
|
great, what have you tried? Please, post your code in python tags and full traceback in error tags if you get any...
And, please, don't use ALL CAPS - it's considered shouting. This time I fixed your title for you. EDIT: It would be useful for everyone who may want to help you to provide information on what database you work on...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
May-16-2018, 02:23 PM
(This post was last modified: May-16-2018, 02:42 PM by PYTHONDUDE.)
import pyodbc
import sys from datetime import date timeimport pygal today = [str(date.today()) ] db = [ ("driver info " "Server = myserver;" "database = mydb;" ] cur = [db.cursor() ] sql = ["SELECT convert(char(10, date_loaded, 126) from my_table" ] cur.execute (sql) if today = sql: continue my code else: send email
May-16-2018, 02:27 PM
Edit/repost with python tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs |
|
Users browsing this thread: 1 Guest(s)