#๐Ÿ”’ Aiosqlite

52 messages ยท Page 1 of 1 (latest)

limpid sierraBOT
#

@primal sparrow

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

worthy cave
#

!paste
use this

limpid sierraBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

primal sparrow
worthy cave
primal sparrow
worthy cave
#

any errors?

#

@primal sparrow one of these are probably not working

#

are the else statements running?

primal sparrow
primal sparrow
worthy cave
#

so then the ifs are false

#

print out result and request.referrer @primal sparrow

worthy cave
#

which is which

#

though i can guess

#

(None,) is result

#

and the key isnt in there

#

do data.fetchall() maybe?

worthy cave
primal sparrow
worthy cave
#

why are you doing if key in result then

primal sparrow
#

The credits

worthy cave
#

is it returning "Invalid Key"?

primal sparrow
#

But the error its not commiting

worthy cave
#

so key is not in result because await data.fetchone() is returning a None

primal sparrow
worthy cave
primal sparrow
worthy cave
#

key is not in result so it is not running the code to commit

#

key needs to be in result

#

or commit wont happen

#

you have this here but it is never running because it never reaches inside of the if

#

you need to put that in the else

#

and then commit

#

@primal sparrow do you understand what im talking about?

primal sparrow
worthy cave
#
keyStore = []
@app.route("/completed/<id>/<key>")
async def complete(id, key):
    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cursor:
            data = await cursor.execute(f"SELECT auth FROM linkvertise WHERE id = {id}")
            result = await data.fetchone()
            if key in result:
                keyStore.append(key)
                if request.referrer and "linkvertise.com" in request.referrer:
                    response = "Added +1 credits to your balance"
                    data = await cursor.execute(f"SELECT credits FROM linkvertise WHERE id = {id}")
                    result = await data.fetchone()
                    await cursor.execute("UPDATE linkvertise SET credits = credits + 1 WHERE id = ?;", (id, ))   
                    await db.commit()
                    return response
                else:
                    response = "Bypass detected"
                    return response
            else:
                await cursor.execute("INSERT INTO linkvertise (id, credits) VALUES (?,?);", (id, 1))
                await db.commit()
                return "something"
```something like this i believe
#

idk if i completely understood

#

but that it what i was talking about]

primal sparrow
#

u need a valid key to get a credits

primal sparrow
# worthy cave ????

If the key and headers are true it adds a credit else it returns invalid key

#

Its not commiting in the headers area

#

!close

limpid sierraBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.