What is the correct path to my database when I deploy heroku?

Viewed 21

I have created a table with SQLAlchemy inside a flask application in this application I implemented a python code to query data in an SQLite database.

database = r"C:\\Users\Stuffs\\Flask\\users.db"

def create_connection(db_file):

    conn = None
    try:
        conn = sqlite3.connect(db_file)
    except Error as e:
        print(e)

    return conn


def insert_value(conn, column, value):
    cur = conn.cursor()
    cur.execute(" UPDATE users SET %s = %s WHERE id=1;" %(column, value))

def users_insert(column, value):

    # create a database connection
    conn = create_connection(database)
    with conn:
        insert_value(conn, column, value)

On the server side I have a python routine that analyzes the occurrence of an event and when it happens the value of one of the database columns is modified.

  • Python code on serve side.
if len(classe)>=2:
     i += 1
     users_insert("value_xbr", str(i))

About my database I follow videos on youtube where the programmer creates the database with sqlite3 and sqlalchemy, when deploying heroku he gets the link 'postgres://blabla....bla' and replaces it with the path he had before.

On my local host the project works perfectly. However, when I deployed it to heroku I caught some errors. To deploy on heroku I change the path of the database located on the local host to link to the development database on Heroku.

My problem is just that, what is the correct path to my database when I deploy heroku?

I would also like to know if there is a better way to do this code, i.e. to change the value of a certain column in the database when a specific event occurs that will be evaluated on the server side.

0 Answers
Related