From a52a2b44af1dc4e26fca4b6eb4fef5c260324634 Mon Sep 17 00:00:00 2001 From: jonasled <jonas@jonasled.de> Date: Fri, 18 Oct 2019 11:13:12 +0200 Subject: [PATCH] removed problems with encoded strings --- export.py | 2 +- import.py | 2 +- main.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/export.py b/export.py index 70d36a5..06bd49e 100644 --- a/export.py +++ b/export.py @@ -21,4 +21,4 @@ conn = sqlite3.connect('db/urls.db') cursor = conn.cursor() res = cursor.execute('SELECT LONG_URL, SHORT_URL FROM WEB_URL WHERE 1') #read all data from database for entries in res.fetchall(): - print(str(entries[1]).replace('"', "") + ";" + str(entries[0]).replace('"', "")) #format the data and print it to console. \ No newline at end of file + print(str(entries[1]).replace('"', "") + ";" + str(entries[0]).replace('"', "")) #format the data and print it to console. \ No newline at end of file diff --git a/import.py b/import.py index ecb6d78..5f937af 100644 --- a/import.py +++ b/import.py @@ -37,6 +37,6 @@ with sqlite3.connect('db/urls.db') as conn: LONG_URL = lines.split(";")[1].replace("\n", "").replace("\r","") #Split the CSV at the ";" then use the seccond one and replace all linebreaks res = cursor.execute( #Insert the data in the SQL table 'INSERT INTO WEB_URL (LONG_URL, SHORT_URL) VALUES (?, ?)', - [LONG_URL, SHORT_URL] + [LONG_URL, SHORT_URL.lower()] ) counter = counter + 1 #Add 1 to counter, for progress \ No newline at end of file diff --git a/main.py b/main.py index 0edee33..8ee5f82 100644 --- a/main.py +++ b/main.py @@ -79,7 +79,7 @@ def home(): return render_template('home.html', builddate=builddate, domain=domain_prepared, snackbar="Please enter a short name, before submitting this form", long_url_prefilled=request.form.get('url'), short_url_prefilled=request.form.get('short').lower(), domain_prefilled=domain_to_index[request.form.get('domain')]) #return the user the prefilled form with an error message, because no short link was provided shorturl = (request.form.get('domain') + "/" + request.form.get('short')).lower() - url = str.encode(request.form.get('url')) + url = request.form.get('url') with sqlite3.connect('db/urls.db') as conn: #Check if another user already used the short link cursor = conn.cursor() res = cursor.execute('SELECT LONG_URL FROM WEB_URL WHERE SHORT_URL=?', [shorturl]) -- GitLab