Пример #1
0
def select(data, table, id):
    try:
        cursor.execute("SELECT {0} from {1} WHERE id='{2}'".format(data, table, id))
        a = str(cursor.fetchone()).replace('(', '').replace(')', '').replace(',', '').replace("'", '').replace("'", '')
        return a
    except:
        logging.exception('-----------------------------------------------')
Пример #2
0
def change_inst(message):
    try:
        cursor.execute("UPDATE const_info SET data = %s WHERE id = 5", message.text)
        connection.commit()
        bot.send_message(message.chat.id, '✅ Успешно.')
    except:
        logging.exception('-----------------------------------------------')
Пример #3
0
def rechange_reviews(message):
    try:
        cursor.execute("DELETE FROM reviews WHERE id = %s", message.text)
        connection.commit()
        bot.send_message(message.chat.id, '✅ Успешно.')
    except:
        logging.exception('-----------------------------------------------')
Пример #4
0
def select_reviews(message):
    try:
        b = []
        cursor.execute("SELECT data from reviews")
        for i in cursor.fetchall():
            a = str(i).replace('(', '').replace(')', '').replace(',', '').replace("'", '').replace("'", '')
            bot.send_message(message.chat.id, a)
    except:
        logging.exception('-----------------------------------------------')
Пример #5
0
def change_reviews(message):
    try:
        a = []
        cursor.execute('SELECT id from reviews')
        for i in cursor.fetchall():
            a.append(str(i).replace('(', '').replace(')', '').replace(',', ''))
        cursor.execute("INSERT INTO reviews VALUES(%s, %s)", (int(max(a)) + 1, message.text))
        connection.commit()
        bot.send_message(message.chat.id, '✅ Успешно.')
    except:
        logging.exception('-----------------------------------------------')
Пример #6
0
from imp import cursor, connection

#cursor.execute('create database telegram_bot')
#connection.commit()

cursor.execute(
    'CREATE TABLE const_info(id INT AUTO_INCREMENT PRIMARY KEY, data TEXT)')
connection.commit()

cursor.execute(
    'CREATE TABLE reviews(id INT AUTO_INCREMENT PRIMARY KEY, data TEXT)')
connection.commit()

cursor.execute("INSERT INTO const_info VALUES (%s, %s)",
               (1, 't.me/heree_name'))
connection.commit()

cursor.execute("INSERT INTO const_info VALUES (%s, %s)", (2, 'yandex.ru'))
connection.commit()

cursor.execute("INSERT INTO const_info VALUES (%s, %s)",
               (3, '*****@*****.**'))
connection.commit()

cursor.execute("INSERT INTO const_info VALUES (%s, %s)", (4, 'все'))
connection.commit()

cursor.execute("INSERT INTO const_info VALUES (%s, %s)", (5, 'fgdfgdfgdfg'))
connection.commit()

cursor.execute("INSERT INTO reviews VALUES (%s, %s)", (1, 'супер'))
Пример #7
0
from imp import cursor, connection

#cursor.execute('create database telegram_bot_1')
#connection.commit()

cursor.execute(
    'CREATE TABLE const_info(id INT AUTO_INCREMENT PRIMARY KEY, data TEXT)')
connection.commit()

cursor.execute(
    'CREATE TABLE reviews(id INT AUTO_INCREMENT PRIMARY KEY, data TEXT)')
connection.commit()