Skip to content

Commit

Permalink
database view added
Browse files Browse the repository at this point in the history
  • Loading branch information
FatihMalakci committed Jul 1, 2019
1 parent 8ef828e commit f9cde5a
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 63 deletions.
110 changes: 82 additions & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 33 additions & 10 deletions database.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
import sqlite3

conn = sqlite3.connect('users.db')
c = conn.cursor()

def connectdatabase(database_name):
conn = sqlite3.connect(f'{database_name}')
print(f"{database_name} database connected.")
c = conn.cursor()
return c

#Creating our table.
c.execute('''CREATE TABLE users
(name,sirname,age,phone number)''')
def createtable(table):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute(f'''CREATE TABLE {table}
(name,sirname,age)''')

# Inserting an example user.
c.execute("INSERT INTO users VALUES('Fatih','Malakçı','24','5419768923')")
def insertuser(name,sirname,age):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute("INSERT INTO users VALUES(?,?,?)",(name,sirname,age))
print(f'User created Name : {name} Sirname : {sirname} Age : {age}')
conn.commit()
conn.close()

#Saving
conn.commit()
def deleteuser(name,sirname):
conn = sqlite3.connect('users.db')
c = conn.cursor()
c.execute(f"DELETE FROM users WHERE name='{name}' AND sirname= '{sirname}'")
print(f"User {name} {sirname} Deleted.")
conn.commit()
conn.close()

#Closing
conn.close()

def databasename():
print('Now using the Users.db database')


if __name__ == '__main__':
gir = input('Enter a database name :')
# createtable(gir)
connectdatabase(gir)
Loading

0 comments on commit f9cde5a

Please sign in to comment.