databases icon indicating copy to clipboard operation
databases copied to clipboard

How to execute multiple queries into multiple tables?

Open justinrest opened this issue 3 years ago • 0 comments

I was trying to do something like this where the table name is part of the values in execute_many but it doesn't work...

        queries = []
        for name in unformatted:
            value = user_data[name]['value']
            leaderboard = name.replace("-",'_')
            queries.append(
                {
                    "table":leaderboard,
                    "uuid":uuid,
                    "user":user,
                    "prefix":prefix,
                    "suffix":suffix,
                    "value":value
                }
            )
            
        await lb_db.execute_many(query="""
            INSERT INTO :table VALUES 
            (:uuid,:user,:prefix,:suffix, :value) 
                ON CONFLICT(uuid) DO UPDATE SET 
            user = :user, prefix = :prefix, suffix = :suffix, value = :value
            """, values=queries)

justinrest avatar Dec 22 '22 23:12 justinrest