B
B
buymyopps2021-05-13 11:14:08
css
buymyopps, 2021-05-13 11:14:08

MySQL not working?

Hello. MySQL code not working. I can't figure out what I'm doing wrong. Instead of displaying information about the online date of a certain user, the program simply creates a bunch of identical fields.
I'm trying to fix the following errors:

mysql.connector.errors.programmingerror: not all parameters were used in the sql statement

mysql.connector.errors.internalerror: unread result found

Here is the code:

spoiler
import sqlite3
import traceback
from time import sleep
import mysql.connector


def check_user(user_id):
    conn = mysql.connector.connect(host='localhost', database='online', user='root1', password='rootRRR111_')
    cur = conn.cursor()
    cur.execute('CREATE TABLE IF NOT EXISTS online(id INT, last_online_date TEXT)')
    conn.commit()
    select = "SELECT * FROM online WHERE id = %s LIMIT 0, 1"

    result = cur.execute(select, (user_id,))
    if result is None:
        insert = ('INSERT INTO online (id, last_online_date) VALUES (%s, %s)')
        cur.reset()
        cur.execute(insert, (user_id, online_time))
        conn.commit()

def update_online_status(user_id, online_time):
    conn = mysql.connector.connect(host='localhost', database='online', user='root1', password='rootRRR111_')
    cursor = conn.cursor()
    select = 'SELECT last_online_date FROM online WHERE id = %s'
    result = cursor.execute(select, (user_id,))
    old_online = result
    online_time = f'{old_online},{online_time}'
    cursor.reset()
    cursor.execute('UPDATE online SET last_online_date = %s WHERE id = %s', (online_time, user_id))
    conn.commit()


app = Client("my_account")
app.start()

while True:
    try:
        with open('ids.ini', 'r') as file:
            users = file.read().splitlines()

        for user in users:
            result = app.get_users(user)

            user_id = result['id']

            if result['status'] == 'offline':
                unix_timestamp = float(result['last_online_date'])
                local_timezone = tzlocal.get_localzone()
                local_time = datetime.fromtimestamp(unix_timestamp, local_timezone)

                online_time = local_time.strftime("%Y/%m/%d %H:%M:%S")

            elif result['status'] == 'online':
                now = datetime.now()
                online_time = now.strftime("%Y/%m/%d %H:%M:%S")

            check_user(user_id)
            update_online_status(user_id, online_time)

        # sleep(300)
    except Exception:
        traceback.print_exc()
        continue


app.stop()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Kot, 2018-11-13
@angry_yum

In swiper this is the Multi Row Slides Layout - set by the slidesPerColumn property
https://idangero.us/swiper/demos/170-slides-per-co...
https://github.com/nolimits4web/Swiper/blob/master.. .everything
else is customizable and styled to your needs
PS That site uses https://elfsight.com/instagram-feed-instashow/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question