I
I
Ivan2021-10-11 19:41:01
Heroku
Ivan, 2021-10-11 19:41:01

Why when downloading a database from heroku, the database is downloaded in its original form?

There is an application in authorization by keys, the keys are stored in the database on the server, the script is fully operational, because it checked everything and more than once on the local server, changes are made, the application did not stop.

Here are the functions from the flask application for working with the database

@app.route("/load", methods=["POST"])
def load_data():
    
    if request.method == 'POST':
        data = request.json
        db = sqlite3.connect('ozon.db')
        cur = db.cursor()
        try:
            key = cur.execute('''SELECT key FROM keys WHERE key="{0}"'''.format(data['key']))
            key = cur.fetchone()
            try:
                if key[0]:
                    cur.execute('''UPDATE keys SET value = "{0}" WHERE key= "{1}"'''.format('1',data['key']))
                    db.commit()
                    key_id = cur.execute('''SELECT id FROM keys WHERE key="{0}"'''.format(data['key']))
                    key_id = cur.fetchone()
                    uuid = cur.execute('''SELECT uuid FROM system WHERE key_id="{0}"'''.format(key_id[0]))
                    uuid = cur.fetchone()
                    if not uuid:
                        cur.execute("""INSERT INTO system VALUES ('{0}','{1}')""".format(data['uuid'],key_id[0]))
                        db.commit()
                        return 'True'
                    else:
                        if uuid[0] == data['uuid']:
                            return 'True'
                        else:
                            return 'False'
            except TypeError:
                return 'False'

        except sqlite3.Error as e:
            if db:
                db.rollback()
                print(e)
        finally:
            if db:
                db.close()
    return 'test'

@app.route("/check", methods=["POST"])
def check_data():
    if request.method == 'POST':
        data = request.json
        db = sqlite3.connect('ozon.db')
        cur = db.cursor()
        try:
            value = cur.execute('''SELECT value FROM keys WHERE key="{0}"'''.format(data['key']))
            value = cur.fetchone()
            try:
                if value[0]:
                    if value[0] == 1:
                        return 'True'
                    else:
                        return 'False'
                else:
                    return 'False'
            except TypeError:
                return 'False'
        except sqlite3.Error as e:
            if db:
                db.rollback()
                print(e)
        finally:
            if db:
                db.close()
               
    return 'test'

Downloaded through file.io
curl -F "[email protected]" https://file.io
I can not understand why.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-10-11
@FCKJesus

Lazy people who didn't bother to read the documentation or use the search ask this question here weekly. And I have been answering for 6 years in a row that Heroku has an ephemeral file system, so SQLite does not work there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question