[Tutor] Regarding Python api script

Alan Gauld alan.gauld at yahoo.co.uk
Wed Dec 5 03:32:24 EST 2018


CCing the list, please use Reply All when responding to the tutor list.


On 05/12/2018 03:44, Ravi Kumar wrote:
> Yes  thats right I want to extract the xml and store into database(SQL
> Server) and I will have to cteate a new table
>
> Here is the sample output I am getting similarly there bulk data which
> I want to store in database format is as shown below
>
>
> b'[{"deviceSerial":"Q2XD-333X-G8Q8","occurredAt":1537565.640085,"type":"802.11
> association","details":{"radio":"1","vap":"0","clientMac":"C8:21:6679:B6:16","channel":"44","rssi":"57","aid":"31645681"}},{"deviceSerial":"Q2XD-97gX-G8Q8","occurredAt":153765.700095,"type":"WPA
> deauthentication","details":{"radio":"1","vap":"0","clientMac":"C621:58:79:B6:16","aid":"316681"}},{"deviceSerial":"Q2XD-97gX-G8Q8","occurredAt":1563369.780085,"type":"WPA
> deauthentication","details":{"radio":"1","vap":"0","clientMac":"C8:21:58:9:B6:16","aid":"31645681"}},{"deviceSerial":"Q297JX-G8Q8"
>
>
> Please let me whether this can be formatted into json in the code

It looks to me like it is already in JSON format.

It is a list of objects.

The json module will let you extract the objects into Python data objects.


> and also any other tips or links to refer if available  to store in
> database

Do you know SQL?

If so using the Python DBAPI is very easy.

If not you will need to learn some basic SQL.

You can try reading the database topic in my Python tutorial(see below)
which is based on SQLite rather than SQL Server but should be 90%
compatible.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list