Python Forum
Python code to check SQL table for current date
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code to check SQL table for current date
#1
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
Reply
#2
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

Reply
#3
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
Reply
#4
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

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 121 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 516 Jan-20-2024, 04:45 AM
Last Post: 1418
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 680 Oct-04-2023, 10:01 AM
Last Post: snippsat
  How to see the date of installation of python modules. newbieAuggie2019 4 1,466 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 1,912 Dec-17-2022, 12:24 AM
Last Post: snippsat
  Multiplication Table code alexsendlegames100 3 1,317 Jun-06-2022, 09:45 AM
Last Post: Gribouillis
  Code to check folder and sub folders for new file and alert fioranosnake 2 1,874 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Date format and past date check function Turtle 5 4,069 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  Try,Except,Else to check that user has entered either y or n (Code block pasted) RandomNameGenerator 3 2,302 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Get the current file name in Python shantanu97 1 2,399 Mar-22-2021, 04:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020