-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ef828e
commit f9cde5a
Showing
5 changed files
with
271 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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) |
Oops, something went wrong.