Simple insert for command to consider all keys in json

77 views
Skip to first unread message

selvamani ashoke kumar

unread,
Oct 24, 2019, 4:46:53 PM10/24/19
to PyMySQL Users
Hi Team,
I have a huge json where i have more than 40+ keys (columns) , is there a simple way to pass the whole in insert query, rather than explicitly mentioning individual column name like INSERT INTO `users` (`email`, `password`) VALUES (%s, %s), please let me know

NAveeN Kumar Reddy

unread,
Nov 2, 2019, 8:46:11 AM11/2/19
to pymysq...@googlegroups.com
Just simple read the whole keys and values separately join them as for string for keys and string of values as you need using loop

1. Convert the whole json to dict then get keys and values separately
2. Join the keys and values as separate strings and please like this 
INSERT INTO `users` ({keys}) VALUES ({values})
it works


On Fri, Oct 25, 2019 at 2:16 AM selvamani ashoke kumar <sashok...@gmail.com> wrote:
Hi Team,
I have a huge json where i have more than 40+ keys (columns) , is there a simple way to pass the whole in insert query, rather than explicitly mentioning individual column name like INSERT INTO `users` (`email`, `password`) VALUES (%s, %s), please let me know

--
You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pymysql-users/a55273fe-138e-46fd-b4e4-ba8d4a0e0dd0%40googlegroups.com.


--
Naveen Kumar  Reddy
Reply all
Reply to author
Forward
0 new messages