diff --git a/Labs/lab-SQL/Lab-SQLite/__pycache__/config.cpython-35.pyc b/Labs/lab-SQL/Lab-SQLite/__pycache__/config.cpython-35.pyc new file mode 100644 index 0000000..6d438dd Binary files /dev/null and b/Labs/lab-SQL/Lab-SQLite/__pycache__/config.cpython-35.pyc differ diff --git a/Labs/lab-SQL/Lab-SQLite/app.db b/Labs/lab-SQL/Lab-SQLite/app.db index a61b799..41f65b1 100644 Binary files a/Labs/lab-SQL/Lab-SQLite/app.db and b/Labs/lab-SQL/Lab-SQLite/app.db differ diff --git a/Labs/lab-SQL/Lab-SQLite/app/__pycache__/__init__.cpython-35.pyc b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000..67f0215 Binary files /dev/null and b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/__init__.cpython-35.pyc differ diff --git a/Labs/lab-SQL/Lab-SQLite/app/__pycache__/forms.cpython-35.pyc b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/forms.cpython-35.pyc new file mode 100644 index 0000000..d033268 Binary files /dev/null and b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/forms.cpython-35.pyc differ diff --git a/Labs/lab-SQL/Lab-SQLite/app/__pycache__/models.cpython-35.pyc b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000..7ac8a86 Binary files /dev/null and b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/models.cpython-35.pyc differ diff --git a/Labs/lab-SQL/Lab-SQLite/app/__pycache__/views.cpython-35.pyc b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/views.cpython-35.pyc new file mode 100644 index 0000000..e21d9d5 Binary files /dev/null and b/Labs/lab-SQL/Lab-SQLite/app/__pycache__/views.cpython-35.pyc differ diff --git a/Labs/lab-SQL/Lab-SQLite/app/forms.py b/Labs/lab-SQL/Lab-SQLite/app/forms.py index a0d42b1..377c5f2 100755 --- a/Labs/lab-SQL/Lab-SQLite/app/forms.py +++ b/Labs/lab-SQL/Lab-SQLite/app/forms.py @@ -5,5 +5,4 @@ class CustomerForm(Form): company = StringField('company', validators=[DataRequired()]) - email = EmailField('email', validators=[DataRequired()]) - + email = EmailField('email', validators=[DataRequired()]) \ No newline at end of file diff --git a/Labs/lab-SQL/Lab-SQLite/app/models.py b/Labs/lab-SQL/Lab-SQLite/app/models.py index 9be98c2..9534bb3 100755 --- a/Labs/lab-SQL/Lab-SQLite/app/models.py +++ b/Labs/lab-SQL/Lab-SQLite/app/models.py @@ -1,7 +1,16 @@ import sqlite3 as sql -def insert_customer(): +def insert_customer(company,email): # SQL statement to insert into database goes here + with sql.connect('app.db') as con: + cur = con.cursor() + cur.execute('INSERT INTO customers (company,email) VALUES (?,?)',(company,email)) + con.commit() def retrieve_customers(): # SQL statement to query database goes here + with sql.connect('app.db') as con: + con.row_factory = sql.Row + cur = con.cursor() + result = cur.execute('SELECT * FROM customers').fetchall() + return result \ No newline at end of file diff --git a/Labs/lab-SQL/Lab-SQLite/app/templates/customer.html b/Labs/lab-SQL/Lab-SQLite/app/templates/customer.html index 6e74a14..59457cf 100755 --- a/Labs/lab-SQL/Lab-SQLite/app/templates/customer.html +++ b/Labs/lab-SQL/Lab-SQLite/app/templates/customer.html @@ -11,6 +11,14 @@
+ Company name:
+ {{form.company(size=120)}}
+
+ Customer email:
+ {{form.email(size=120)}}
+