-
Notifications
You must be signed in to change notification settings - Fork 130
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
CLI : Add data directly without running server. #168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure your code is PEP8 compliant.
@chrizandr I have made the required changes. Although, I have one doubt regarding the SQL Session. I am using the crud methods to add data to the database. So does the DB get reset every time we start the server, or uses the previous state? |
That depends on the database that you use. If the user had not specified the database, we use a temporary one using sqlite. This one will be deleted once the session is closed. This is an issue, good that you noticed it. We need to come up with a workaround for this. Maybe use the same session with which you add data, for the server. |
@chrizandr to fix the database issue, i have added another option to the CLI while adding data from json, the user will have to mention the database url to which the data must be added. This way, the data will not be lost. What are your views on this? |
Note: we don't have a database configuration file yet? Database choice should be defined at deploy time (sqlite by default). The app should know already where its storage is, without the CLI user to specify. |
@Mec-iS this is only for the adddata option. When a user wants to start the server using the CLI, the default sqlite is used in case he doesn't explicitly mention a database. Is that what you meant or am i missing something? |
Something like:
First thing to do: have/locate the variable/module where the database configuration is stored. |
As of now, we take input of the database url, for example, Line 30 in 42612ef
|
That's what I meant. Database's uri and credentials have to be moved to a configuration file where all the other modules can read them. This configuration variables have to be set at deploy time (by Docker?). Please open the issues to accomplish this layout. [EDIT] For example, they can also be stored in a text file, loaded into variables at runtime for now. |
Ideally, the configuration variables should be stored as environment variables. You can provide defaults but they should only be used when environment variables are not present. One interesting thing that can be done is using the CLI to set This could easily be implemented with Docker as well. |
Are there any other changes that need to be made? @chrizandr |
|
@suryatejreddy Please consider adding a "Changes log" section in your PR comment to follow this PR template Also you can consider squashing your commits as there are multiple commits with same commit message. |
Thanks for the review @ashwani99 , @Mec-iS . I am working on the changes. |
a1d402f
to
1740726
Compare
@suryatejreddy Have the changes been made ? |
@py-ranoid All the necessary changes have been made. I am in the testing phase now. |
Fixes #167
Checklist
Description
Added a new option to the cli called
additems
that allows the user to load contents to the database directly without starting the server. The option expects ajson
file and theAPI doc
.As of now the following format of data is supported,
[{"Prop1":"Value1","Prop2":"Value2","@type":"dummyClass"},{"Prop1":"Value1","Prop2":"Value2","@type":"dummyClass"}]
Support for more data formats can be added later.
Test Logs