Question: I'm trying to query a database using Python/Pandas. This will be a recurring request where I'd like to look back into a window of time that changes over time, so I'd like to use some smarts in how I do this.

In my SQLite query, if I say

```
WHERE table.date BETWEEN DATETIME('now', '-6 month') AND DATETIME('now')

```

I get the result I expect. But if I try to move those to variables, the resulting table comes up empty. I found out that the endDate variable does work but the startDate does not. Presumably I'm doing something wrong with the escapes around the apostrophes? Since the result is coming up empty it's like it's looking at `DATETIME(\'now\')` and not seeing the `'-6 month'` bit (comparing now vs. now which would be empty). Any ideas how I can pass this through to the query correctly using Python?

```
startDate = 'DATETIME(\'now\', \'-6 month\')'
endDate = 'DATETIME(\'now\')'
query = '''
SELECT some stuff
FROM table
WHERE table.date BETWEEN ? AND ?
'''
df = pd.read_sql_query(query, db, params=[startDate, endDate])

```

Answer: 
As you are using same input array to display table value and input value, when input data changes table data changes with it. I would recommend adding one more state object for table value.

```
import React, { useState } from "react";

export default function Form() {
  const [input, setInput] = useState([{ firstName: "" , lastName: "", email: ""} ]);
  const [tableValue, setTableValue] = useState([]);
  const [view, setView] = useState("Hide");

  let getValue = (i, e) => {
    ...
  }
  let addFormFields = () => {
    ...
  }

  let removeFormFields = (i) => {
    ...
  }

  let formSubmit = (event) => {
    event.preventDefault();
    let arr = [];
    for(let i in input) {
      arr.push({...input[i]})
    }
    setTableValue(arr)
    setView("Show")
  }

  return (
    <>
    <div className='form-box'>
      <form onSubmit={formSubmit} >
        ...
      </form>
    </div>

    {view === "Show" ? <Table TableData={tableValue}/> : null}
    </>
  )
}

function Table(props) {
  ...
}

```
***Issues**: after submitting value it shown in table but if I add another field and type it directly updating my table without submitting.* it's not your issue, actually changing in form always updates table immediately , but since in the first render `view` state is equal to `Hide` actually you never render table, if you change it you can see that when you type something in the first form, it immediately updates the table. To solve the proble you can separate table's data and form's data, I implemented a simple example [Here](https://stackblitz.com/edit/react-gpspfd). You can check it out.