Python Forum
Python code to check SQL table for current date - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python code to check SQL table for current date (/thread-10178.html)



Python code to check SQL table for current date - PYTHONDUDE - May-16-2018

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


RE: PYTHON CODE TO CHECK SQL TABLE FOR CURRENT DATE - buran - May-16-2018

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...


RE: Python code to check SQL table for current date - PYTHONDUDE - May-16-2018

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


RE: Python code to check SQL table for current date - buran - May-16-2018

Edit/repost with python tags