object oriented design – Frameworks for creating dynamic SQL

We are trying to create a Data platform where users are uploading data and creating dashboards.
I am trying to abstract the SQl execution process. Currently, a custom object is created for every request, which is then converted into an SQL using string builders.
Are there any frameworks that can help in the dynamic SQL creation?

I checked out MDX which works on OLAP which has a predefined schema, trying to research frameworks that on run time can take the schema and help in the SQL generation.

Are there any frameworks which support such a requirement.

dynamic – Dows MousePosition[“Graphics”] gives coordinates in an outermost Graphics?

It seems that this issue has been raised a few times, but what exactly does MousePosition(“Graphics”) answer?

This code

Dynamic @ p
  Disk(), {"MouseMoved" :> (p = MousePosition("Graphics"))}))

nicely displays mouse position in the “current graphics” coordinate.

But try to put the graphics in another Graphics (GraphicsColumn in this case):

Dynamic @ p
GraphicsColumn @ 
 List @ Graphics(
    Disk(), {"MouseMoved" :> (p = MousePosition("Graphics"))}))

The coordinates now seem to be in the coordinate system defined by GraphicsColumn.

I will greatly appreciate any answer with a workaround (even not so generic solution).

P.S. Interesting enough GraphicsColumn breaks LocatorPane behaviour. LocatorPane manages to get correct coordinates (it uses custom LocatorPaneBox) but locators do not display:

pts = {};
GraphicsColumn @ 
 List @ LocatorPane(Dynamic(pts), Graphics(Circle()), 
   LocatorAutoCreate -> All)

dynamic programming – CSES Problem Set : Two Sets Problem

I saw the solution given below but could not understand the part where we only involve subsets upto n-1 term. Can anybody please explain?

This is a 0-1 knapsack in disguise. If we are to have two subsets of equal sum, they must sum to half the total sum each. 
This means if the total sum n(n+1)/2 is odd, the answer is zero (no possibilities). Otherwise we run 0-1 knapsack to get the number of ways to reach n(n+1)/4 using subsets of the numbers 1..n-1. 

Why n-1? Because by only considering numbers up to n-1, we always put n in the second set, and therefore only count each pair of sets once(otherwise we count every pair of sets twice).

visualization – How to include a meter in Manipulate that shows a value calculated from the manipulate dynamic variable?

I’m trying to make a visualization of grid (representing magnetic states) and I want to include a meter that shows a variable calculated from the manipulate index (of the form J1/J2 = (index)*0.1) so that as you change the index next to the array plot you see the numerical value of J1/J2. Any idea how to do this?

Here’s my code:

Manipulate( ArrayPlot(MontesJ((i, 1)),  ColorRules -> {1 -> White, -1 -> Black}), {i, 1, 20, 1})

Montes((i,1)) is a square grid.

query – MySQL Dynamic Result view with column when values are on same column

I want to create a dynamic value based on election result. I’ve three table.

  1. vote table
  2. Candidate table
  3. Candidate position table.

Here the candidate table and position table is dynamic. its means I haven’t any control on it.

I want to make a view like this:
enter image description here

Here Ballton num come from vote table, president, general secretary and treasurer is come from candidate position table and against each ballot no all column will be populate.

Here are the rest of the table structure:

enter image description here

enter image description here

Candidate position:
enter image description here

postgresql – Create dynamic sql query to select all related data in DB based on entry table and ID

Hope all is well. I am hoping you can help me.

Problem Statement – I’m tasked to create a dynamic SQL statement which will select all related data from a given table where the Identifier is passed. For each table where the relevant data is found i would like the data to be exported onto a separate tab of within excel

If i was doing this manually done this i would perform the following queries and export the data onto each tab;

Select * from  Mason where id = 12345
Select * from  MasonContacts where Companyid= 12345 
Select * from  MasonOpportunities  where Comid = 12345 

However given the sheer volume of tables this isn’t viable.

Step 1 : Type in my identifier (in this case my identifier is a field called “Id” in the Table “Mason”) The query will always start from this table.

Table Name : Mason
Field : Id = “12345”

Step 2 : Search against table “MasonContacts”, search against the field “Companyid”. Return all columns & records where the field “Companyid = 12345”

Table Name : MasonContacts
Field : Companyid

Step 3 : Search against table “Mason Opportunities “, search against the field “Comid”. Return all columns & records where the field “Company = 12345”

Table Name : MasonOpportunities
Field : Comid

Looking forward to your help

magento2 – How to Send a Copy of Order Confirmation Emails to Dynamic EmailId in Magento 2

I have a made custom module of the sales rep. They can create an order for a customer. When sales rep place order at that time order confirmation email copy sent to assign sales reps in order.

I have store sales rep email id in Quote & order both tables. If any query please let me know. Please any can help me

Note: The code is working on the local server. But In an enterprise, it’s not working.

  1. create an event for a set variable. create event.xml

     <event name="email_order_set_template_vars_before">
         <observer name="set_email_po_order" instance="VendorModulenameObserverEmailOrderSetTemplateVarsBefore" />
  2. set variable dynamic from the get order table

     namespace VendorModulenameObserver;
     use MagentoFrameworkEventObserver;
     use MagentoFrameworkEventObserverInterface;
     class EmailOrderSetTemplateVarsBefore implements ObserverInterface {
     private $orderEmail;
     protected $scopeConfig;
     public function __construct(
         VendorModulenameModelOrderEmail $orderEmail,
         VendorModulenameModelSalesrepFactory $salesrepData,
         MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
         $this->orderEmail = $orderEmail;
         $this->_salesrepData = $salesrepData;
         $this->scopeConfig = $scopeConfig;
     public function execute(Observer $observer)
         $transportObject = $observer->getData('transportObject');
             try {
                     $getSalesrepData = $this->_salesrepData->create()->load($order->getSalesrepId());          
                         $notiEmails = $getSalesrepData->getEmail();
                         $logger->debug("Order email copy send to salesrep sucessfully....");
             } catch (Exception $e) {
                 $logger->error('Error while send design customer Email', ('exception' => $e));
                 echo $e->getMessage(); 


  3. create a model for set private

     namespace VendorModulenameModel;
     class OrderEmail {
     private $extraOrderEmailId;
     public function setSalesrepEmails($email){
         $this->extraOrderEmailId = $email;
     public function getSalesrepEmails()
         return $this->extraOrderEmailId;


  4. Add plugin di.xml

     <type name="MagentoSalesModelOrderEmailContainerOrderIdentity">
             <plugin name="add_email_to_order_copy" type="VendorModulenamePluginOrderEmailContainerOrderIdentity" sortOrder="1" disabled="false" />
  5. Create a plugin file

      namespace VendorModulenamePluginOrderEmailContainer;    
      class OrderIdentity{
          public function __construct(
             VendorModulenameModelOrderEmail $orderEmail
              $this->orderEmail = $orderEmail;
           public function afterGetEmailCopyTo(
           MagentoSalesModelOrderEmailContainerOrderIdentity $subject,
     $additionalEmailId =  $this->orderEmail->getSalesrepEmails();
     if(($additionalEmailId === null) || (!$additionalEmailId) || empty($additionalEmailId)){
         return $result;
         $additionalEmailId =  explode(",",$this->orderEmail->getSalesrepEmails());
         if(count($additionalEmailId)==0 || empty($additionalEmailId)){
             return $result;
             if (!empty($result) && is_array($result)){
                 foreach($additionalEmailId as $additionalEmail):
                     $result() = (string) $additionalEmail;
                 return $result;
                 return $additionalEmailId;

How to make this Google Sheets script dynamic?

I’m working in a script to paste a table on the same sheet, in my code I’m only pasting the table on the row A18

function NewQuote() {
 var ss = SpreadsheetApp.getActive();
 ss.getRange('A1:F14').copyTo(ss.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);

I want to make this value dynamic and pasting the table on the next available row.

Dynamic URL based on keyword

I’m trying to integrate Tradingview charts to my wordpress site. I will store stock name in my database. Suppose someone searches for AAPL, the url should have AAPL as the stock name and accordingly, tradingview should load AAPL chart on my website. So basically if I’m storing stock_name in my database and user clicks on AAPL, url should return something like this:


Trading embed code is like:

<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
  <div id="tradingview_1f858"></div>
  <div class="tradingview-widget-copyright"><a href="https://in.tradingview.com/symbols/**stock_name**/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
  <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
  <script type="text/javascript">
  new TradingView.widget(
  "width": 980,
  "height": 610,
  "symbol": "**stock_name**",
  "interval": "D",
  "timezone": "Etc/UTC",
  "theme": "light",
  "style": "1",
  "locale": "in",
  "toolbar_bg": "#f1f3f6",
  "enable_publishing": false,
  "allow_symbol_change": true,
  "container_id": "tradingview_1f858"
<!-- TradingView Widget END -->

So I wish to dynamically pass stock_name both in URL as well as in the embed code.

dynamic programming – What is the difference between these two Edit Distance Algorithm

Edit Distance is very well known problem in computer science. Came up with following algorithm after reading through CLRS but it doesn’t work. Check the working algorithm below, I couldn’t find why first algorithm doesn’t work while second one does.

  public int find (String word1, String word2, int i, int j, int count) {
    if (i >= word1.length()) return  count + word2.length() - j;
    if (j >= word2.length()) return  count + word1.length() - i;

    if (dp(i)(j) != -1) return dp(i)(j);

    if (word1.charAt(i) == word2.charAt(j)) {
        dp(i)(j) = find(word1, word2, i+1, j+1, count);
    } else {
        int replace = find(word1, word2, i+1, j+1, count + 1);
        int delete = find(word1, word2, i+1, j, count + 1);
        int insert = find(word1, word2, i, j+1, count + 1);
        dp(i)(j) = Math.min(replace, Math.min(delete, insert));

    return dp(i)(j);

Notice, how I’m passing the cost of edit in method argument. Now, the algorithm which works. Here I’m not passing the edit distance in the method parameter instead of I’m adding 1 to recursive method.

  public int find (String word1, String word2, int i, int j) {
    if (i >= word1.length()) return  word2.length() - j;
    if (j >= word2.length()) return  word1.length() - i;

    if (dp(i)(j) != -1) return dp(i)(j);

    if (word1.charAt(i) == word2.charAt(j)) {
        dp(i)(j)  = find(word1, word2, i+1, j+1, count);
    } else {
        int replace = find(word1, word2, i+1, j+1, count + 1);
        int delete = find(word1, word2, i+1, j, count + 1);
        int insert = find(word1, word2, i, j+1, count + 1);
        dp(i)(j) = 1 + Math.min(replace, Math.min(delete, insert));

    return dp(i)(j);

I’m not able to think why first algorithm fails. Appreciate, if you can point my error in understanding.