Skip to main content

Posts

Showing posts with the label Sqlite3

How to Use sqlite-utils to Create Tables from JSON Input

There are many way to query JSON data. This article focuses on one of those possible ways using few developer utility tools.  jqplay.org :  https://jqplay.org/s/nwxNZ7LOY6 sqlite3:  https://www.sqlite.org/cli.html sqlite-utils:  https://sqlite-utils.datasette.io/en/stable/cli.html#inserting-json-data You can call an HTTP API as below. Use jq to transform the return content as you need. Then pipe it through sqlite-utils to perform upsert. Following code snippet simply creates a "test" table with primary key being the id attribute.  curl --location --request POST 'https://seyfi.net/searches?size=1000&page=0' \ --header 'Authorization: Bearer XXXXXX' \ --header 'Content-Type: application/json' \ --data-raw '{"date":"2019-01-01T00:00:00.000Z"}' | jq '.content' | sqlite-utils upsert /tmp/test.db content - --pk=id Once this executes, you can then filter this and export easily using Sqlite3 as follows. >sqlite3...

How to use Android Debug Bridge to copy data out of your Android device

I recently built an Android application that had the capability to export data in XML format to the devices external storage directory. External storage directory path in Android OS can be accessed using the android.os.Environment package. Following code return the path for the external storage directory:  Environment.getExternalStorageDirectory().getPath() To copy data from this storage into your local device, you can use the Android Debug Bridge command line tool which comes installed with the Android SDK platform.  The following command will pull a single file named filename.ext out of the device and copy it to your local computer: adb pull /sdcard/filename.ext ./filename.ext If you want to copy multiple files with certain extension to your local computer you can use Adb's shell command capability.  The following command will pull all files with .xml extension to your local file for example: adb shell ls /sdcard/*.xml | tr '\r' '...