I am looking at some older Python scripts that I am modernising and within query strings they used this format:
query = " SELECT DISTINCT account from customers..accounts WHERE date = '" + date + "'" cursor.execute(query) I would have thought this should be performed this by using the following format:
query = " SELECT DISTINCT account from customers..accounts WHERE date = {}".format(date) cursor.execute(query) When would you use the original format? Is there a reason to use it? Does it concatenate? Why would you concat within a SQL query?
Personally I have always run my sybase queries using the module:
cursor.execute("SELECT DISTINCT account from customers..accounts WHERE date = @date", {"@date": date})
+on strings is concatenation.