Esempio n. 1
0
 def update(name, lastname, phone, email, password, id):
     cursor = mysql.get_db().cursor()
     #cursor = mysql.cursor()
     cursor.execute(
         'update register set name = %s,lastname = %s,phone = %s,email = %s,password = %s WHERE id = %s',
         (
             name,
             lastname,
             phone,
             email,
             password,
             id,
         ))
     mysql.get_db().commit()
     cursor.close()
Esempio n. 2
0
 def auth_user(self, email):
     cursor = mysql.get_db().cursor()
     cursor.execute(
         "SELECT email,password,user,id FROM users WHERE email=%s", (email))
     data = cursor.fetchone()
     cursor.close()
     return data
Esempio n. 3
0
 def listUrlsUser(self, id):
     cursor = mysql.get_db().cursor()
     cursor.execute("""SELECT url_shorten, url_to_shorten
                     FROM urls_sht WHERE user_id = %s""", (id,))
     data = cursor.fetchall()
     cursor.close()
     return data
Esempio n. 4
0
 def listUrls(self):
     cursor = mysql.get_db().cursor()
     cursor.execute(
         'SELECT url_shorten, url_to_shorten FROM urls_sht')
     data = cursor.fetchall()
     cursor.close()
     return data
Esempio n. 5
0
 def redirect_url(self, url_shortened):
     cursor = mysql.get_db().cursor()
     cursor.execute(
         'SELECT url_to_shorten FROM urls_sht WHERE url_shorten = %s', (url_shortened,))
     data = cursor.fetchone()
     cursor.close()
     return data[0]
Esempio n. 6
0
 def update(name, lastname, phone, email, password, id):
     cursor = mysql.get_db().cursor()
     #cursor = mysql.cursor()
     cursor.execute(
         'update register set name = ?,lastname = ?,phone = ?,email = ?,password = ? WHERE id = ?',
         (
             name,
             lastname,
             phone,
             email,
             password,
             id,
         ))
     mysql.get_db().commit()
     cursor.close()
     print(data)
Esempio n. 7
0
    def create(self, user: UserDTO):
        cursor = mysql.get_db().cursor()
        #cursor = mysql.cursor()
        cursor.execute(
            """insert into user 
            (name,lastname,phone,email,password) 
            values (%s,%s,%s,%s,%s)""", (
                user.name,
                user.lastname,
                user.phone,
                user.email,
                user.password,
            ))

        mysql.get_db().commit()
        cursor.close()
Esempio n. 8
0
 def lists(self):
     cursor = mysql.get_db().cursor()
     #cursor = mysql.get_db().cursor()
     cursor.execute('select * from user')
     data = cursor.fetchall()
     cursor.close()
     print(data)
     return data
Esempio n. 9
0
 def create(self, name, lastname, phone, email, password):
     cursor = mysql.get_db().cursor()
     #cursor = mysql.cursor()
     cursor.execute(
         'insert into user (name,lastname,phone,email,password) values (% s,% s,% s,% s,% s)',
         (name, lastname, phone, email, password))
     flash('User added successfully!')
     cursor.close()
Esempio n. 10
0
    def lists(self):
        cursor = mysql.get_db().cursor()
        #cursor = mysql.get_db().cursor()
        cursor.execute('select * from user')

        fields_name = [field[0] for field in cursor.description]
        data = cursor.fetchall()

        response = []

        for index, d in enumerate(data):
            response.append({})
            for index_field, field in enumerate(fields_name):
                response[index][fields_name[index_field]] = d[index_field]

        cursor.close()
        print(data)
        return response
Esempio n. 11
0
 def generate_short_link(self, url_to_shorten, url_shortened, user_id):
     cursor = mysql.get_db().cursor()
     cursor.execute('insert into urls_sht (url_shorten,url_to_shorten, user_id) values (%s,%s,%s)',
                    (url_shortened, url_to_shorten,user_id))
     mysql.get_db().commit()
     cursor.close()
Esempio n. 12
0
 def create_user(self, user, email, password):
     cursor = mysql.get_db().cursor()
     cursor.execute('insert into users (user,email,password) values (%s,%s,%s)',
                    (user,email,password))
     mysql.get_db().commit()
     cursor.close()
Esempio n. 13
0
 def deleteUrl(self, url_shorten):
     cursor = mysql.get_db().cursor()
     cursor.execute("DELETE FROM urls_sht WHERE url_shorten = %s", (url_shorten,))
     mysql.get_db().commit()
     cursor.close()       
Esempio n. 14
0
 def delete(id):
     cursor = mysql.get_db().cursor()
     #cursor = mysql.cursor()
     cursor.execute('delete from register where id = ?', (id))
     cursor.close()