Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup embeddable database #19

Open
Lelelo1 opened this issue Nov 6, 2021 · 9 comments
Open

Setup embeddable database #19

Lelelo1 opened this issue Nov 6, 2021 · 9 comments
Labels
Requirement Things that need to get implemented for a successful project Technical Technical implementation details

Comments

@Lelelo1
Copy link
Owner

Lelelo1 commented Nov 6, 2021

Setup SQLite in Haxe
As I want the search to be embeddable in the client I need to setup a working database interaction. SQLite exists in the Sys package in haxe, and Open Street Map has it's data in it.
However since my primary target now being .net - it is unclear how to set up the needed driver: https://community.haxe.org/t/sqlite-in-c-target/3270/2 I will use a .net standard nuget package with SQLite driver and functionality init.

For other targets like cocoa I would use the C++ driver and set it up later.

Using haxe means I can have shared resources. But is a bit unclear what the path to .db would be.

Also it can be seen as a separate project to create cross platform embeddable db as a haxelib. It could depend on native packages and/or native drivers. Then set up in way the client/developer can read and write any data to it.

It needs to be assured also that the data is persistent between app start, on mobile for instance...

@Lelelo1 Lelelo1 added Technical Technical implementation details Requirement Things that need to get implemented for a successful project labels Nov 6, 2021
@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 6, 2021

Seems like there is libraries for cross database: https://lib.haxe.org/t/database/
They have not been updated for long time but looks reliable.

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 6, 2021

It seems like I can create an internal database and object relational mapping. The haxlib has is updated and has many downloads: https://github.com/HaxeFoundation/record-macros
I will test and see if it also includes the necessary drivers on each platform

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 7, 2021

It seems bit completed to work with orm, and running the sample code resulted in errors.

This the following json db haxelib seem to be simple to work with, and it says it works on all Sys targets.
It has not been updated for a while, but I will try it!: https://github.com/ciscoheat/haxelow

@Lelelo1 Lelelo1 changed the title Setup SQLite in Haxe Setup embeddable database in Haxe Nov 10, 2021
@Lelelo1 Lelelo1 changed the title Setup embeddable database in Haxe Embeddable database Nov 10, 2021
@Lelelo1 Lelelo1 changed the title Embeddable database Setup Embeddable database Nov 10, 2021
@Lelelo1 Lelelo1 changed the title Setup Embeddable database Setup embeddable database Nov 10, 2021
@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 10, 2021

I will setup the db and make a test on a Xamarin Forms android device. And on cocoa I will run it on watchOS os via Xcode in the way that the watchOSDummySample was made with haxe-c-bridge

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 10, 2021

Then I will have to structure the data in a good way

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 13, 2021

It does not seem like in an agnostic file path can be made unless creating in memory db. I think it should be possible to read the shipped db as resources (json) and create a in memory db out of it, to use in the search in the client.

This means it can't permanently written to at runtime, but I don't that would be advisable to do any way. Here is a sketch:

The in memory db is created at runtim - using it for search of categorical tags. The resources should be created when building the library and tags are assembled


I will see if in memory reading from resource works in dotnet target and cocoa (via haxe-c-bridge)

@Lelelo1 Lelelo1 mentioned this issue Nov 13, 2021
@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 13, 2021

I choose to go with sqlite. Since multiple .db files are needed for specifying language - I will be looking to see if it is possible to read and write persistent (disk saved) database files in haxe, and test in Xamarin Forms on android, and in cocoa for apple watch.

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 14, 2021

To test it out I am first checking so that. can save and read a text field in haxe, on Android iOS, watchOS. It was not possible with default
Screen Shot 2021-11-14 at 14 56 45

var filename = "./testTags.txt";
    var output = File.write(filename, false);
    output.writeString(text);
    output.close();
    
    Sys.println("read written file...");
    var input = File.read(filename, false);
    var gotText = input.readLine();

So I am looking for other means with some haxelib maybe to do it

@Lelelo1
Copy link
Owner Author

Lelelo1 commented Nov 14, 2021

The path needs to given from the client, here is docs with xamarin: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/data/databases

There should be something similar in swift (cocoa) for watchOS, probably NSPersistentContainer. I needed to update my apple watch to test it out more.

I will setup a test method which writes the TestTags to file specified with url - then reading them from file. In cocoa, this step will have to be made with care - as mentioned by haxiomic in haxe-c-bridge I will need specking a TestTag.h and declare a custom array type. It should also be stack allocated and copied in client
But I will test with dotnet first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requirement Things that need to get implemented for a successful project Technical Technical implementation details
Projects
None yet
Development

No branches or pull requests

1 participant