Python Forum

Full Version: Python code to check SQL table for current date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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...
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
Edit/repost with python tags