Python Forum
Problem With Database Calls and Load
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem With Database Calls and Load
#1
Hi, I have created an API service using FastAPI, Python and MySQL. The API allows acces to some data in a database. An api request from fastapi triggers a function call which runs two database read queries that then return a result. The database is accessed using mysql.connector and a cursor. If just one api request is made every few seconds, everything seems to work. However, any faster than that (if i hit the refresh button in browser quickly) the program seems to crash at the point the second db query is made. The database contains quite a few records, so with just 1 request being made that can take 1-5 seconds on average for the second db call. Does anyone know what might be going wrong and a solution? I am a newbie so quite likely I have done something a bit silly.
Reply
#2
I think I fixed it, I wasn't opening/closing the database connection properly Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calls to Attributes of a Class SKarimi 3 3,340 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  Problem updating value in MySQL database dangermaus33 1 1,589 Nov-24-2020, 08:32 PM
Last Post: dangermaus33
  list call problem in generator function using iteration and recursive calls postta 1 1,863 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  sqlite3 database problem Maryan 2 2,428 Oct-05-2020, 05:21 AM
Last Post: buran
  Telegram bot - Problem with database NoNameoN 1 1,616 Jul-13-2020, 06:39 AM
Last Post: Gribouillis
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,875 Dec-11-2019, 07:50 AM
Last Post: parsley
  Need help with a function that calls other functions. skurrtboi 4 2,461 Sep-30-2019, 09:28 PM
Last Post: stullis
  Testing function calls jenselme 1 2,652 Jul-25-2018, 10:33 AM
Last Post: Larz60+
  function state between calls Skaperen 5 5,083 Feb-08-2018, 02:20 AM
Last Post: Skaperen
  Is there another way to do a bunch of methods calls ? Windspar 7 4,624 Jan-02-2018, 06:26 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

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