-
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
FrankGrossman
committed
Jun 11, 2021
0 parents
commit 9c74a72
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Imports | ||
import sqlite3 | ||
# Establish connection to database | ||
conn = sqlite3.connect('python.db') | ||
c = conn.cursor() | ||
# Create global variable name | ||
name = "" | ||
|
||
def create_table(): | ||
global name # Retrieve global variable name | ||
c.execute('CREATE TABLE IF NOT EXISTS RecordONE (Number REAL, Name TEXT)') # DB execution | ||
name = input("What is your name?") # Input to global variable name | ||
|
||
def data_entry(): | ||
number = "1234" | ||
c.execute("INSERT INTO RecordONE (Number, Name) VALUES(?, ?)", (number, name)) # Execute sql | ||
|
||
# Call functions | ||
create_table() | ||
data_entry() | ||
|
||
# Save changes to DB | ||
conn.commit() | ||
|
||
# Close connection | ||
c.close() | ||
conn.close() |
Binary file not shown.