Python Forum
How to insert JSON into MSSQL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to insert JSON into MSSQL
#1
Hello guys,

I implemented a flask REST api. I want to insert JSON data into MSSQL 2016. I wonder if I can use OPENJSON in my python.I installed pyodbc and connect to MSSQL. How can I use insert statment like below in my python code?

INSERT INTO SalesReport  
SELECT SalesOrderJsonData.*  
FROM OPENJSON (@jsonVariable, N'$.Orders.OrdersArray')  
           WITH (  
              Number   varchar(200) N'$.Order.Number',   
              Date     datetime     N'$.Order.Date',  
              Customer varchar(200) N'$.AccountNumber',   
              Quantity int          N'$.Item.Quantity'  
           )  
  AS SalesOrderJsonData;  
Best Regards.
Reply
#2
Any help please?
Reply
#3
I don't normally do this buuut... https://goo.gl/hZKBCm
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python connect to mssql wailoonho 7 1,397 Dec-07-2023, 02:06 AM
Last Post: wailoonho
  MSSQL query not working in Python kat35601 0 874 Apr-12-2022, 06:44 PM
Last Post: kat35601
  from MSSQL to excel kat35601 1 1,622 Apr-11-2022, 06:19 PM
Last Post: buran
  [split] How to insert JSON into MSSQL gehrenfeld 3 3,255 Jan-27-2019, 06:20 PM
Last Post: micseydel
  Interface Arduino and MSSQL using Python MichaelDean 0 2,862 Nov-18-2018, 05:00 PM
Last Post: MichaelDean
  how do I successfully use PDO with my ODBC for MSSQL? cyberion1985 3 6,525 Jun-26-2018, 04:44 PM
Last Post: Maverick494
  Insert using psycopg giving syntax error near "INSERT INTO" olgethorpe 4 15,494 Jul-21-2017, 07:39 PM
Last Post: nilamo
  Insert JSON into dict shanz1999 2 3,610 Feb-23-2017, 03:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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