?

Log in

No account? Create an account

...

или внеочередные заметки


Previous Entry Share Next Entry
SQL/JSON on android phone
trekking, Himalaya
obartunov
Update:

We updated packages:
http://www.sai.msu.su/~megera/postgres/files/postgresql-sqljson_11.0-dev-2_aarch64.deb
http://www.sai.msu.su/~megera/postgres/files/postgresql-sqljson_11.0-dev-2_arm.deb
They now automatically initialize the data directory, start server and load demo table 'house.sql'. Also, the history file .psql_history automatically created, so you can play with queries (use arrow up and down keys).

===========================================================================================


Nikita Glukhov has managed to compile the postgresql(master branch) + sql/json patches for Termux, so now it's possible to play with sql/json on android phone, using deb-file postgresql-sqljson_11.0-dev-0_aarch64.deb.

You can download the sample database to play with examples in Jsonpath Introduction.



In case you need more details:


0. Install Termux from Google play. I also installed "Hacker keyboard" to be comfortable with command line.
1. Make sure Termux has access to /sdcard ( check under "Settings"->"Apps"->"Termux"->Permissions"->Storage)
2. Download on your phone deb-file postgresql-sqljson_11.0-dev-0_aarch64.deb. Another option is to install curl ( pkg install curl) and then download deb-file directly to your home directory.
3. Run 'dpkg -i /Sdcard/Download/postgresql-sqljson_11.0-dev-0_aarch64.deb'.
4. Initialize cluster 'initdb -D ~/data'
5. Run postgres 'pg_ctl -D ~/data start'
6. psql -d postgres


Example table house.sql:

CREATE TABLE house(js) AS SELECT jsonb '
{
  "info": {
    "contacts": "Postgres Professional\n+7 (495) 150-06-91\ninfo@postgrespro.ru",
    "dates": ["01-02-2015", "04-10-1957 19:28:34 +00", "12-04-1961 09:07:00 +03"]
  },
  "address": {
    "country": "Russia",
    "city": "Moscow",
    "street": "117036, Dmitriya Ulyanova, 7A"
  },
  "lift": false,
  "floor": [
    {
      "level": 1,
      "apt": [
        {"no": 1, "area": 40, "rooms": 1},
        {"no": 2, "area": 80, "rooms": 3},
        {"no": 3, "area": null, "rooms": 2}
      ]
    },
    {
      "level": 2,
      "apt": [
        {"no": 4, "area": 100, "rooms": 3},
        {"no": 5, "area": 60, "rooms": 2}
      ]
    }
  ]
}

';





  • 1

Thanks for this great hint.

I can try examples with postgresql on my phone or tablet, now.
Always and everywhere.
:-)

  • 1