NameError and AttributeError while inserting variables in SQLite3 table with Tkinter?
I wanted to make a text-file manager, but I'm stuck at the login/sign-up page. My program takes inputs (Name, Last name, username and password) from the user and stores them all in a database. However, I can't retrieve the said data because every time I try, I end up with either a NameError (uname not defined (uname is global everywhere)) or an AttributeError (str object does not have .get()). Here is a small piece of my code:
def login_check():
global password, uname
checkpass=cur.execute("SELECT Password from Sample WHERE Uname = (?);",(uname.get()),)
conn.commit;
if checkpass==password.get():
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
Here's how I've taken the entry for the username in a different function:
uname=Entry(spp)
uname.grid(row=3, column=1)
cur.execute("insert into Sample values (?, ?, ?, ?)", (fname.get(), lname.get(), uname.get(), password.get()));
The program ran well and didn't show the errors only until recently. I can't add the entire code here because it is too large, but I'd really appreciate it if someone could suggest what I could do to improve it. Thanks!
python database sqlite tkinter sqlite3
add a comment |
I wanted to make a text-file manager, but I'm stuck at the login/sign-up page. My program takes inputs (Name, Last name, username and password) from the user and stores them all in a database. However, I can't retrieve the said data because every time I try, I end up with either a NameError (uname not defined (uname is global everywhere)) or an AttributeError (str object does not have .get()). Here is a small piece of my code:
def login_check():
global password, uname
checkpass=cur.execute("SELECT Password from Sample WHERE Uname = (?);",(uname.get()),)
conn.commit;
if checkpass==password.get():
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
Here's how I've taken the entry for the username in a different function:
uname=Entry(spp)
uname.grid(row=3, column=1)
cur.execute("insert into Sample values (?, ?, ?, ?)", (fname.get(), lname.get(), uname.get(), password.get()));
The program ran well and didn't show the errors only until recently. I can't add the entire code here because it is too large, but I'd really appreciate it if someone could suggest what I could do to improve it. Thanks!
python database sqlite tkinter sqlite3
add a comment |
I wanted to make a text-file manager, but I'm stuck at the login/sign-up page. My program takes inputs (Name, Last name, username and password) from the user and stores them all in a database. However, I can't retrieve the said data because every time I try, I end up with either a NameError (uname not defined (uname is global everywhere)) or an AttributeError (str object does not have .get()). Here is a small piece of my code:
def login_check():
global password, uname
checkpass=cur.execute("SELECT Password from Sample WHERE Uname = (?);",(uname.get()),)
conn.commit;
if checkpass==password.get():
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
Here's how I've taken the entry for the username in a different function:
uname=Entry(spp)
uname.grid(row=3, column=1)
cur.execute("insert into Sample values (?, ?, ?, ?)", (fname.get(), lname.get(), uname.get(), password.get()));
The program ran well and didn't show the errors only until recently. I can't add the entire code here because it is too large, but I'd really appreciate it if someone could suggest what I could do to improve it. Thanks!
python database sqlite tkinter sqlite3
I wanted to make a text-file manager, but I'm stuck at the login/sign-up page. My program takes inputs (Name, Last name, username and password) from the user and stores them all in a database. However, I can't retrieve the said data because every time I try, I end up with either a NameError (uname not defined (uname is global everywhere)) or an AttributeError (str object does not have .get()). Here is a small piece of my code:
def login_check():
global password, uname
checkpass=cur.execute("SELECT Password from Sample WHERE Uname = (?);",(uname.get()),)
conn.commit;
if checkpass==password.get():
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
Here's how I've taken the entry for the username in a different function:
uname=Entry(spp)
uname.grid(row=3, column=1)
cur.execute("insert into Sample values (?, ?, ?, ?)", (fname.get(), lname.get(), uname.get(), password.get()));
The program ran well and didn't show the errors only until recently. I can't add the entire code here because it is too large, but I'd really appreciate it if someone could suggest what I could do to improve it. Thanks!
python database sqlite tkinter sqlite3
python database sqlite tkinter sqlite3
asked Nov 22 at 19:43
Soumya Mukhija
76
76
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This a workaround from me to check if the data inserted in the entry is valid data in db. Since you didn't paste column name for password i did it P_word
change that to password column name in your table.
This will check if the data is valid before it will open the main window
if not messagebox
will pop up. Make sure you close the login window after opening main window.
def login_check():
global password, uname
con = sqlite3.connect("database_name.db") # your database should be name
cur = con.cursor()
attempt = ("SELECT * FROM Password WHERE Uname=? AND P_word=?") # column to check name n password
cur.execute(attempt, (uname.get(), password.get()))
rows = cur.fetchall()
if rows:
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437228%2fnameerror-and-attributeerror-while-inserting-variables-in-sqlite3-table-with-tki%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This a workaround from me to check if the data inserted in the entry is valid data in db. Since you didn't paste column name for password i did it P_word
change that to password column name in your table.
This will check if the data is valid before it will open the main window
if not messagebox
will pop up. Make sure you close the login window after opening main window.
def login_check():
global password, uname
con = sqlite3.connect("database_name.db") # your database should be name
cur = con.cursor()
attempt = ("SELECT * FROM Password WHERE Uname=? AND P_word=?") # column to check name n password
cur.execute(attempt, (uname.get(), password.get()))
rows = cur.fetchall()
if rows:
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
add a comment |
This a workaround from me to check if the data inserted in the entry is valid data in db. Since you didn't paste column name for password i did it P_word
change that to password column name in your table.
This will check if the data is valid before it will open the main window
if not messagebox
will pop up. Make sure you close the login window after opening main window.
def login_check():
global password, uname
con = sqlite3.connect("database_name.db") # your database should be name
cur = con.cursor()
attempt = ("SELECT * FROM Password WHERE Uname=? AND P_word=?") # column to check name n password
cur.execute(attempt, (uname.get(), password.get()))
rows = cur.fetchall()
if rows:
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
add a comment |
This a workaround from me to check if the data inserted in the entry is valid data in db. Since you didn't paste column name for password i did it P_word
change that to password column name in your table.
This will check if the data is valid before it will open the main window
if not messagebox
will pop up. Make sure you close the login window after opening main window.
def login_check():
global password, uname
con = sqlite3.connect("database_name.db") # your database should be name
cur = con.cursor()
attempt = ("SELECT * FROM Password WHERE Uname=? AND P_word=?") # column to check name n password
cur.execute(attempt, (uname.get(), password.get()))
rows = cur.fetchall()
if rows:
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
This a workaround from me to check if the data inserted in the entry is valid data in db. Since you didn't paste column name for password i did it P_word
change that to password column name in your table.
This will check if the data is valid before it will open the main window
if not messagebox
will pop up. Make sure you close the login window after opening main window.
def login_check():
global password, uname
con = sqlite3.connect("database_name.db") # your database should be name
cur = con.cursor()
attempt = ("SELECT * FROM Password WHERE Uname=? AND P_word=?") # column to check name n password
cur.execute(attempt, (uname.get(), password.get()))
rows = cur.fetchall()
if rows:
mainscreen()
else:
mb.showerror('Login Failed','Username or Password incorrect. Please retry.')
answered Nov 23 at 6:12
AD WAN
8551215
8551215
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
add a comment |
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
You can comment if you need any assistant.
– AD WAN
Nov 23 at 6:12
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
@Soumya Mukhija if the answer solves your problem make sure you tick it as reference for future coders.
– AD WAN
Nov 23 at 9:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437228%2fnameerror-and-attributeerror-while-inserting-variables-in-sqlite3-table-with-tki%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown