def threaddes(part_number): query = '''SELECT a.[Name] ,d.[Name] FROM [LocknutData].[dbo].[ThreadDiameter] a INNER JOIN [LocknutData].[dbo].[MeasurementUnit] b on b.MeasurementUnitID = a.MeasurementUnitID INNER JOIN [LocknutData].[dbo].[Pitch2ThreadDiameter] c on c.ThreadDiameterID = a.ThreadDiameterID INNER JOIN [LocknutData].[dbo].[Pitch] d on d.PitchID = c.PitchID INNER JOIN [LocknutData].[dbo].[PartNumber] e on e.Pitch2ThreadDiameterID = c.Pitch2ThreadDiameterID Where e.Name = '{}';''' \ .format(part_number) result = cursor.fetchall() for item in result: threaddesc = item[0] + ' x ' + item[1] return threaddesc # # Stop using the query cursor.close()
def nicknames(uuid): cursor.execute("SELECT * FROM plan_nicknames WHERE uuid=%s", (uuid, )) data = cursor.fetchall() dData = {} lData = [] for registro in data: dData = {"name": registro[2], "last_used": registro[4]} lData.append(dData) return lData
def pitch(sqlid): cursor.execute('''SELECT c.Name FROM [LocknutData].[dbo].[Pitch2ThreadDiameter] a INNER JOIN [LocknutData].[dbo].[Pitch] b on b.PitchID = c.PitchID WHERE a.ThreadDiameterID = '{}';'''.format(sqlid)) return cursor.fetchall() cursor.close()
def diameterid(sqlid): cursor.execute('''SELECT b.ThreadDiameterID FROM [LocknutData].[dbo].[Pitch2ThreadDiameter] a INNER JOIN [LocknutData].[dbo].[ThreadDiameter] b on b.ThreadDiameterID = a.Pitch2ThreadDiameterID WHERE a.PitchID = {:d};'''.format(sqlid)) return cursor.fetchall() cursor.close()
def query_request(query, type="GET"): if type == "GET": cursor.execute(query) data = cursor.fetchall() return data
import random from main import db, cursor, bot, get_username_or_first_name, awake_mysql_db def create_markup_pin(): markup_pin = telebot.types.InlineKeyboardMarkup() markup_pin.row(telebot.types.InlineKeyboardButton("Pin", callback_data="pin"), telebot.types.InlineKeyboardButton("Dismiss", callback_data="dismiss")) return markup_pin awake_mysql_db() # Check if there was a birthday yesterday ------------------------------------------------------------------ cursor.execute("SELECT * FROM was_birthday") was_birthdays = cursor.fetchall() for past_birthday in was_birthdays: chat_id_of_past_birthday, new_photo_of_past_birthday_id, old_photo_of_past_birthday_id = past_birthday # If users blocked the bot, it won't be able to find the chat ------------------------------------------ try: chat = bot.get_chat(chat_id_of_past_birthday) except telebot.apihelper.ApiException: chat = None if not chat: sql = "DELETE FROM birthdays WHERE Chat_Id = %s" val = (chat_id_of_past_birthday,) cursor.execute(sql, val) db.commit() continue # Set photo which was before person's birthday as a chat photo again -----------------------------------