0

I want to create a temporary table for the user result and the user_id variable, but if several users use the database, the table and variable will be recreated. How can I isolate database usage for multiple users? I heard about connections, but based on the fact that there are only 150 connections by default, I thought they were for other purposes. I also heard about transactions, but I have nothing to roll back, so maybe this tool is not for me. I also do not want to add different "id" for the variable "user_id" because it is confusing What should I use?

Short example:

def create connection(user_id):
cursor.execute('SET @user_id = %s' ,(user_id,))
cursor.execute('CREATE TEMPORARY TABLE user_resulte AS (SELECT column FROM results WHERE column = @user_id)')

p.s. I'm a novice in databases :)

2
  • why do you need a temporary table at all. Anormal table, with user id and result, can hold you everything you need as far as i understand
    – nbk
    Commented May 16, 2020 at 15:12
  • Because as I thought, function COUNT(), that I need may be applied only to table, but this is wrong, I also can use the AS keyword :) Commented May 16, 2020 at 20:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.