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

Parameterized Query inside the datetime function #376

Open
robonetphy opened this issue Nov 16, 2022 · 2 comments
Open

Parameterized Query inside the datetime function #376

robonetphy opened this issue Nov 16, 2022 · 2 comments

Comments

@robonetphy
Copy link

robonetphy commented Nov 16, 2022

Hey There,
It been long time since we are using your library, but I have one query for you that is it possible to add parameterize internal function of sqlite like as follow:

  // Define Queries
  std::string insert_counting_log_query = "INSERT INTO log VALUES (NULL, :job_name, :part_name,\n"
       ":batch_name,   datetime('now','-:time_passed second', 'localtime'), datetime('now', 'localtime'));";
  // need to note batch start and end time.
  // end time can be note with datetime('now','localtime')
  // for start time I have number of seconds before the job started as passed time
  // looking for feature like datetime('now','-:time_passed second', 'localtime')
@dougnazar
Copy link
Contributor

This should already work. However, you can't pass in a parameter into a string, but you can pass in the full string.

Something like

INSERT INTO log VALUES (NULL, :job_name, :part_name,
       :batch_name, datetime('now', :time_passed, 'localtime'), datetime('now', 'localtime')

then bind with

query.bind("time_passed", "-30 second");

@robonetphy
Copy link
Author

robonetphy commented Dec 25, 2022

@dougnazar Thanks for the solution. My doubts are resolved.
@SRombauts Pls let me know if you are planning for these enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants