Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4006_deffer_project-email/Email_db.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
75 lines (53 sloc)
1.95 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from tools import email_client | |
conn = sqlite3.connect(':memory:') #creating database in memory | |
e = conn.cursor() #declaring cousor | |
e.execute("""CREATE TABLE email_client ( | |
email_id text, | |
options text, | |
subf integer | |
)""") #creating table | |
def ins_usr(usr): #function for inserting user | |
with conn: | |
e.execute("INSERT INTO email_client " | |
"VALUES (:email_id, :options, :subf)", | |
{'email_id': usr.email_id, 'options': usr.options, 'subf': usr.subf}) | |
return 0 | |
def user_info (email_id): #function for selecting user | |
e.execute("SELECT * " | |
"FROM email_client " | |
"WHERE email_id=:email_id", | |
{'email_id': email_id}) | |
return e.fetchall() | |
def Alluser_info(): #function for all selecting users | |
e.execute("SELECT * " | |
"FROM email_client ") | |
return e.fetchall() | |
def upd_options(email_id, options): #function for upadting user's options | |
with conn: | |
e.execute("""UPDATE email_client | |
SET options = :options | |
WHERE email_id = :email_id""", | |
{'email_id': email_id, 'options': options}) | |
return 0 | |
def remove_usr(usr): # functiob for removing user | |
with conn: | |
e.execute("DELETE from email_client " | |
"WHERE email_id = :email_id ", | |
{'email_id': usr.email_id}) | |
return 0 | |
def upd_subf(email_id, subf): #function for upadting user's subf | |
with conn: | |
e.execute("""UPDATE email_client | |
SET subf = :subf | |
WHERE email_id = :email_id""", | |
{'email_id': email_id, 'subf': subf}) | |
#def send_all(usr): | |
# with conn: | |
# c.execute("SELECT * " | |
# "FROM email_client ") | |
#def run_background1(): | |
# with conn: | |
# c.execute("SELECT * " | |
# "FROM email_client ") | |
# return c.fetchall() | |