Python Forum
Python keeps inserting NULL values into table
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python keeps inserting NULL values into table
#11
Really? Named parameters are written as %(name)s and there are examples here (see the paragraph starting "Named arguments").
Reply
#12
db.execute("INSERT INTO users (username, password) VALUES (%s, %s)", ("username", "password",))

I tried this and i'm getting this error:

AttributeError: 'tuple' object has no attribute 'keys'
Reply
#13
Urgh, I've just realised you're using SQLAlchemy - you might need to check their docs too. I don't know if it does something different to the query parameters over what Psycopg2 does. Is there a reason you're using both SQLAlchemy and Psycopg? I'd think you just want to use one or the other; using both is just going to cause you and others confusion I imagine.
Reply
#14
I've changed my code so much i don't know what I"m doing anymore. I've been seeking help for over a month now. No one can help me get it to work - i don't get it.

It should be as simple as "this is wrong - this is how u fix it".

no one can explain it to me yet.

doesn't matter what I use - I just need it to work. I'd like to use SQLAlchemy
Reply
#15
Make sure that what you get from request.form.get('username') is indeed the user input. You were printing username and password. What you get printed? That will show that the problem is in the DB part. Given it insert NULL, I guess for whatever reason request.form.get('username') might be returning None, in which case it's not DB related issue at all
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#16
yes it is printing out "none". That's the issue. I can't figure out why..
Reply
#17
So, forget about the DB - it's not DB related, but Flask/form handling
What you get if you print(request.form) when request.method is POST?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#18
https://www.picpasteplus.com/v.php?i=786e902f35

This is what is shows. Why does it say t_password?

i figured it out i was using the wrong html!
Reply
#19
(Jun-09-2020, 06:52 AM)card51shor Wrote: i figured it out i was using the wrong html!
yeah, that's it
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with number of rows containing null values PythonSpeaker 3 2,247 Nov-23-2019, 06:53 PM
Last Post: ibreeden
  Issues with Inserting Values into an Empty List with a While Loop TommyMer 2 3,777 Sep-12-2018, 12:43 AM
Last Post: TommyMer
  file a table of values Ybivashka322 4 3,718 Dec-14-2017, 06:11 PM
Last Post: mpd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020