Python Forum
Trying to send input from html form to database SQLite3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to send input from html form to database SQLite3
#4
Yes the error message is crucial and tells exactly what is wrong.
Now I do not know SQLite3 so perhaps I'm not the right person to investigate, but I think you are messing around with the variable "conn". You seem to expect a global version and a local version. In "create_connection()" you create a connection (conn is local in that function). In line 21 you use the function but you do not assign the result to anyting, so the result of the connection gets lost.
In "main()" line 48 you do it right:
conn = create_connection(database)
But the "conn" variable remains local in the "main()" function.
In "my_form()" in line 70 things go wrong (as the error message says). You do:
c = conn.cursor()
... but conn is not available, neither local nor global.
I would suggest you remove line 21 (it does nothing in your program, but it may keep a connection open on your database thus using resources) and add a line conn = create_connection(database) to the function "my_form()".
Like I said I do not know SQLite3, but in general everything that has been opened should be closed too. So both the cursor and the connection should be closed somewhere I guess.
Reply


Messages In This Thread
RE: Trying to send input from html form to database SQLite3 - by ibreeden - Dec-21-2019, 02:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create SQLite3 database with peewee Jim53_1980 2 714 Dec-20-2023, 02:38 PM
Last Post: buran
  Regex replace in SQLite3 database WJSwan 1 828 Dec-04-2023, 05:55 PM
Last Post: Larz60+
  Webscrape from my webpage and store in database and send to grafana Armond 2 947 Jul-12-2023, 06:29 PM
Last Post: Armond
  Rows not adding to sqlite3 database using SQLAlchemy Calab 11 1,831 Jun-02-2023, 05:53 PM
Last Post: bowlofred
  pyscript index error while calling input from html form pyscript_dude 2 1,014 May-21-2023, 08:17 AM
Last Post: snippsat
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 960 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,422 Nov-08-2022, 07:16 PM
Last Post: marlonbown
Sad how to validate user input from database johnconar 3 1,980 Sep-11-2022, 12:36 PM
Last Post: ndc85430
  Use pexpect to send user input alisha17 0 1,929 May-10-2022, 02:44 AM
Last Post: alisha17
  Error creating database with python and form? shams 3 2,402 Aug-02-2021, 02:00 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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