Recent

Author Topic: Nosql  (Read 1375 times)

Prakash

  • Full Member
  • ***
  • Posts: 169
Nosql
« on: December 04, 2022, 10:07:29 am »
How to create nosql database in Lazarus with encrypted

Чебурашка

  • Hero Member
  • *****
  • Posts: 566
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Nosql
« Reply #1 on: December 04, 2022, 07:02:24 pm »
Can you be a little more specific?

Which DBMS are you referring to?
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Prakash

  • Full Member
  • ***
  • Posts: 169
Re: Nosql
« Reply #2 on: December 05, 2022, 02:10:07 am »
I don't know which DBMS I have to use
I want to store everything in json

It should be easy to insert,delete,select and json should be compressed

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Nosql
« Reply #3 on: December 05, 2022, 03:51:06 am »
I don't see explicitly what you are looking for here: https://wiki.freepascal.org/Databases#Supported_databases

On can do NoSQL (Json records) with SQLite. (I've not tried it).

And SQLite does does support encryption.

Were you doing this in some other language and looking for the same with Lazarus/FPC?




KodeZwerg

  • Hero Member
  • *****
  • Posts: 2006
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Nosql
« Reply #4 on: December 05, 2022, 04:03:34 am »
I don't know which DBMS I have
:o How about to inform yourself before asking such?

SQLite does does support encryption.
You can easy encrypt before adding to table and decrypt on getting content.
I mean, possibility exists, that I wanted to say  O:-) If it is smart or dumb is written on a different paper  ::)
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

PierceNg

  • Sr. Member
  • ****
  • Posts: 369
    • SamadhiWeb
Re: Nosql
« Reply #5 on: December 05, 2022, 04:10:16 am »
On can do NoSQL (Json records) with SQLite. (I've not tried it).

I've stored and queried JSON with SQLite. Works fine.

I'd say the use case is when external source data to be stored in database is already JSON and there is no requirement to deconstruct said data like normalization. Otherwise when programming in OO style one will typically use an ORM to go between 'native objects' and RDBMS structures; JSON doesn't need to come into the picture.

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Nosql
« Reply #6 on: December 05, 2022, 04:17:59 am »
SQLite does does support encryption.
You can easy encrypt before adding to table and decrypt on getting content.
I mean, possibility exists, that I wanted to say  O:-) If it is smart or dumb is written on a different paper  ::)

Heh, yeah, really know what Prakash's expectations are...

Encryption...
Compression...

Seems like what is expected is some sort of "simple???" encrypted/compressed JSON "data-store" back-end... I've used "similar" in python, but won't say they are all that good... (especially compare to some proper DBMS).

I only mentioned SQLite because it seems like some "simple???" non server back-end is desired here based on what little information is provided... (yes, should not "guess"...)

@Prakash, more details are needed as to your expectations, and if you have been doing this already with some some other languages (if you are trying to match functionality).

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: Nosql
« Reply #7 on: December 05, 2022, 09:44:56 am »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Prakash

  • Full Member
  • ***
  • Posts: 169
Re: Nosql
« Reply #8 on: December 05, 2022, 11:20:18 am »
Thanks Everyone .

We have selected sqlcipher(sqllite) for this project . It does database encryption .

We can store json inside text field .

it is having all json support  .


Prakash

  • Full Member
  • ***
  • Posts: 169
Re: Nosql
« Reply #9 on: December 05, 2022, 11:22:05 am »
CREATE TABLE "users" (
   "id"   INTEGER NOT NULL,
   "full_name"   TEXT NOT NULL,
   "email"   TEXT NOT NULL,
   "created"   DATE NOT NULL,
   "phone"   TEXT,
   PRIMARY KEY("id")
);

insert into users (full_name,email,created, phone) values("packs","abc@gmail.com" ,
"01-01-2022",json('{"cell":"+491765", "home":"+498973"}'));

update users
   set phone =(select json_replace(users.phone,'$.cell',200) from users where full_name = 'packs')
   where full_name == 'packs';






Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: Nosql
« Reply #10 on: December 05, 2022, 11:27:28 am »
CREATE TABLE "users" (
   "id"   INTEGER NOT NULL,
   "full_name"   TEXT NOT NULL,
   "email"   TEXT NOT NULL,
   "created"   DATE NOT NULL,
   "phone"   TEXT,
   PRIMARY KEY("id")
);

insert into users (full_name,email,created, phone) values("packs","abc@gmail.com" ,
"01-01-2022",json('{"cell":"+491765", "home":"+498973"}'));

update users
   set phone =(select json_replace(users.phone,'$.cell',200) from users where full_name = 'packs')
   where full_name == 'packs';
See in red.
DON'T
Use ISO-Format "YYYY-MM-DD"
Quote
where full_name == 'packs';
There is an '=' too much.....
Code: SQL  [Select][+][-]
  1. UPDATE users
  2. SET phone =json_replace(phone,'$.cell',200)
  3. WHERE full_name = 'packs';
  4.  
No need for the Sub-SELECT
« Last Edit: December 05, 2022, 11:36:11 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Prakash

  • Full Member
  • ***
  • Posts: 169
Re: Nosql
« Reply #11 on: December 05, 2022, 11:42:18 am »
THANKS.

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: Nosql
« Reply #12 on: December 05, 2022, 11:55:51 am »
Some suggestions/food for thought:
I see the tablename "users"
Set the Columns "full_name" and "email" to UNIQUE each (not combined!).
Especially since i see that "... WHERE full_name='packs'"
That way a "full_name" as well as an "email" can only be entered/used once

Next: Why use json at all?
This is a "classic" 1:m relation
One user can have multiple phone-numbers, but any phone-number can only belong to one user.

I'd even think about moving "email" to a child-table, since a user can have multiple email-addresses
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Prakash

  • Full Member
  • ***
  • Posts: 169
Re: Nosql
« Reply #13 on: December 05, 2022, 12:28:09 pm »
we want to save unstructured data in our application . which is developed in lazarus.




Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: Nosql
« Reply #14 on: December 05, 2022, 12:36:55 pm »
we want to save unstructured data in our application . which is developed in lazarus.
OK for the unstructered Data.
But it's got nothing to do, if it's written in Lazarus/FPC or in Sanskrit.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018