Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A rolling disk gathers no MOS.


devel / comp.lang.tcl / Substituting variable

SubjectAuthor
* Substituting variableCecil Westerhof
+- Substituting variableRich
+- Substituting variableheinrichmartin
+* Substituting variableAlan Grunwald
|`* Substituting variableCecil Westerhof
| +* Substituting variableRich
| |+- Substituting variableCecil Westerhof
| |`* Substituting variableRalf Fassel
| | +* Substituting variablegreg
| | |`- Substituting variablegreg
| | +* Substituting variableCecil Westerhof
| | |`* Substituting variableRich
| | | `- Substituting variablegreg
| | `* Substituting variableSchelte
| |  `* Substituting variableCecil Westerhof
| |   +* Substituting variableSchelte
| |   |`* Substituting variableCecil Westerhof
| |   | `- Substituting variableSchelte
| |   `* Substituting variableRolf Ade
| |    +- Substituting variablegreg
| |    `* Substituting variableCecil Westerhof
| |     `- Substituting variableRalf Fassel
| `* Substituting variableAlan Grunwald
|  `- Substituting variableCecil Westerhof
`* Substituting variableMole Cool
 +* Substituting variableHarald Oehlmann
 |`* Substituting variableMole Cool
 | `* Substituting variableRich
 |  `* Substituting variableMole Cool
 |   `- Substituting variableRich
 `* Substituting variableCecil Westerhof
  `* Substituting variablerene
   `- Substituting variableCecil Westerhof

Pages:12
Substituting variable

<87bkcpgi1k.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12301&group=comp.lang.tcl#12301

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Substituting variable
Date: Mon, 23 Oct 2023 23:12:07 +0200
Organization: Decebal Computing
Lines: 19
Message-ID: <87bkcpgi1k.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="97b8a42aaee19235417478a6648501c1";
logging-data="3564027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c+tbSTmVYa5jtjK+LT7Nta1jCrVQiHDE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:EUlc2tA+Ox7GrPa4oNeZgdv/azE=
sha1:Bpdos4GWook4Zw39mT+QTwNHAJA=
 by: Cecil Westerhof - Mon, 23 Oct 2023 21:12 UTC

I have the following code:
set selectWeek {
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, SUM(dayViews) AS WeekTotals
FROM dayViews
WHERE WeekNo >= ${startWeek}
AND WeekNo <= ${endWeek}
GROUP BY WeekNo
ORDER BY WeekNo
}

Only later the values for startWeek and endWeek are determined. When
they are determined, is there a possibility to have the right values
substituted, or should I work with format?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<uh70u4$3eo9n$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12302&group=comp.lang.tcl#12302

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Mon, 23 Oct 2023 23:51:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <uh70u4$3eo9n$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl>
Injection-Date: Mon, 23 Oct 2023 23:51:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ea36629333d6b9e5663e504570242ac5";
logging-data="3629367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sbXBlj6G55xh9/Tdi2ObV"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:T4iemsXAW+ZnuCGzKqK9AyZ5gdo=
 by: Rich - Mon, 23 Oct 2023 23:51 UTC

Cecil Westerhof <Cecil@decebal.nl> wrote:
> I have the following code:
> set selectWeek {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo >= ${startWeek}
> AND WeekNo <= ${endWeek}
> GROUP BY WeekNo
> ORDER BY WeekNo
> }
>
> Only later the values for startWeek and endWeek are determined. When
> they are determined, is there a possibility to have the right values
> substituted, or should I work with format?

Read up on the [subst] command. It is intended for this type of
substituting within strings.

Re: Substituting variable

<f24131dc-2a03-4296-b38e-302bb4839344n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12305&group=comp.lang.tcl#12305

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:222d:b0:775:7523:b698 with SMTP id n13-20020a05620a222d00b007757523b698mr189616qkh.3.1698131494158;
Tue, 24 Oct 2023 00:11:34 -0700 (PDT)
X-Received: by 2002:a9d:5544:0:b0:6b9:cc6b:275a with SMTP id
h4-20020a9d5544000000b006b9cc6b275amr3072860oti.3.1698131493840; Tue, 24 Oct
2023 00:11:33 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 24 Oct 2023 00:11:33 -0700 (PDT)
In-Reply-To: <87bkcpgi1k.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=91.217.55.78; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 91.217.55.78
References: <87bkcpgi1k.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f24131dc-2a03-4296-b38e-302bb4839344n@googlegroups.com>
Subject: Re: Substituting variable
From: martin.h...@frequentis.com (heinrichmartin)
Injection-Date: Tue, 24 Oct 2023 07:11:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: heinrichmartin - Tue, 24 Oct 2023 07:11 UTC

On Monday, October 23, 2023 at 11:14:08 PM UTC+2, Cecil Westerhof wrote:
> I have the following code:
> set selectWeek {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo >= ${startWeek}
> AND WeekNo <= ${endWeek}
> GROUP BY WeekNo
> ORDER BY WeekNo
> }
>
> Only later the values for startWeek and endWeek are determined. When
> they are determined, is there a possibility to have the right values
> substituted, or should I work with format?

There might be another option depending on the package you are using. I know from tdom[1] and Pgtcl[2] that support variable injection.

[1] http://tdom.org/index.html/file?name=doc/domNode.html&ci=tip "At every place where the XPath syntax allows a node test there could be a Tcl variable reference (in any form), just the leading $ replaced with %."
[2] https://flightaware.github.io/Pgtcl/html/pgtcl-pgexecprepared.html "args consists of zero or more optional values that can be inserted, unquoted, into the SQL statement using $-style substitution."

Actually, take care about the input - you could introduce a dormant bug or a security hole using Tcl's subst or format!

HTH
Martin

Re: Substituting variable

<uh8a7p$3rmmh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12307&group=comp.lang.tcl#12307

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam.n...@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Tue, 24 Oct 2023 12:36:25 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <uh8a7p$3rmmh$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Oct 2023 11:36:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b259d8e21278bdcff820a8371c7cf833";
logging-data="4053713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KvqJQp76X8B3ZzbVHgOfJzcCO3TGZWPw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/LyKqIUeLuGqU+06Aj+8cAozRUQ=
In-Reply-To: <87bkcpgi1k.fsf@munus.decebal.nl>
Content-Language: en-US
 by: Alan Grunwald - Tue, 24 Oct 2023 11:36 UTC

On 23/10/2023 22:12, Cecil Westerhof wrote:
> I have the following code:
> set selectWeek {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo >= ${startWeek}
> AND WeekNo <= ${endWeek}
> GROUP BY WeekNo
> ORDER BY WeekNo
> }
>
> Only later the values for startWeek and endWeek are determined. When
> they are determined, is there a possibility to have the right values
> substituted, or should I work with format?
>
How are you executing the SQL?

If you're using tdbc, then you can, and should, change your WHERE clause to

WHERE WeekNo >= :startWeek
AND WeekNo <= :endWeek

tdbc will substitute the values of the startWeek and endWeek variables
when it executes the query if they are in scope.If they aren't in scope,
then you can specify the values by passing a dictionary when you
evaluate the SQL text.

IMHO, If you aren't using tdbc, then you should be.

Alan

Re: Substituting variable

<877cncgl6r.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12308&group=comp.lang.tcl#12308

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Tue, 24 Oct 2023 16:16:28 +0200
Organization: Decebal Computing
Lines: 45
Message-ID: <877cncgl6r.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="e49b3587799f7c49ce0d30e2862a94e4";
logging-data="12303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vXgmjbJx4QAN3LNLXwAEF0c8kq5aFN1Y="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:2PMyR8noyPkE4mjyR9SVmUo+DJ8=
sha1:Tvrj0q5BLHzhNSgF4axbj79+0IA=
 by: Cecil Westerhof - Tue, 24 Oct 2023 14:16 UTC

Alan Grunwald <nospam.nurdglaw@gmail.com> writes:

> On 23/10/2023 22:12, Cecil Westerhof wrote:
>> I have the following code:
>> set selectWeek {
>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> , SUM(dayViews) AS WeekTotals
>> FROM dayViews
>> WHERE WeekNo >= ${startWeek}
>> AND WeekNo <= ${endWeek}
>> GROUP BY WeekNo
>> ORDER BY WeekNo
>> }
>> Only later the values for startWeek and endWeek are determined. When
>> they are determined, is there a possibility to have the right values
>> substituted, or should I work with format?
>>
> How are you executing the SQL?

'package require sqlite3' and 'db eval …'

> If you're using tdbc, then you can, and should, change your WHERE clause to
>
> WHERE WeekNo >= :startWeek
> AND WeekNo <= :endWeek

That was it. I knew it could be done, but did not remember how.

Should use the tclsh/sqlite combo more often.

> tdbc will substitute the values of the startWeek and endWeek variables
> when it executes the query if they are in scope.If they aren't in scope,
> then you can specify the values by passing a dictionary when you
> evaluate the SQL text.
>
> IMHO, If you aren't using tdbc, then you should be.

I am not using tdbc. What are the advantages of it?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<uh8sem$2h6g$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12309&group=comp.lang.tcl#12309

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Tue, 24 Oct 2023 16:47:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uh8sem$2h6g$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me> <877cncgl6r.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Oct 2023 16:47:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ea36629333d6b9e5663e504570242ac5";
logging-data="83152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oUsSomIPp73OhaX8y4ygw"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:5V+r/5gfnDEUHKsIXaq8fXoCeh8=
 by: Rich - Tue, 24 Oct 2023 16:47 UTC

Cecil Westerhof <Cecil@decebal.nl> wrote:
> Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
>> How are you executing the SQL?
>
> 'package require sqlite3' and 'db eval …'
>
>
>> If you're using tdbc, then you can, and should, change your WHERE
>> clause to
>>
>> WHERE WeekNo >= :startWeek
>> AND WeekNo <= :endWeek
>
> That was it. I knew it could be done, but did not remember how.

Sqlite's Tcl API supports three different ways to "substitute" (which
one to use depends upon exactly what it is that is in the variable).

The docs at: https://sqlite.org/tclsqlite.html explain all three in the
description of the "eval" method.

Re: Substituting variable

<8734xzhlxx.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12311&group=comp.lang.tcl#12311

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Tue, 24 Oct 2023 21:14:50 +0200
Organization: Decebal Computing
Lines: 30
Message-ID: <8734xzhlxx.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="e49b3587799f7c49ce0d30e2862a94e4";
logging-data="163726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uNEDI+i01CcyFybb1icZnrMxx0nMlDy0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Kh1VzFcix7GDo3Xcg0gVwyXz8Y0=
sha1:I+LDhdHetWegCtoFBFijP5Lmc1A=
 by: Cecil Westerhof - Tue, 24 Oct 2023 19:14 UTC

Rich <rich@example.invalid> writes:

> Cecil Westerhof <Cecil@decebal.nl> wrote:
>> Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
>>> How are you executing the SQL?
>>
>> 'package require sqlite3' and 'db eval …'
>>
>>
>>> If you're using tdbc, then you can, and should, change your WHERE
>>> clause to
>>>
>>> WHERE WeekNo >= :startWeek
>>> AND WeekNo <= :endWeek
>>
>> That was it. I knew it could be done, but did not remember how.
>
> Sqlite's Tcl API supports three different ways to "substitute" (which
> one to use depends upon exactly what it is that is in the variable).
>
> The docs at: https://sqlite.org/tclsqlite.html explain all three in the
> description of the "eval" method.

I will look into it. But I am quite sure that in the past I also use
':'. But it is never wrong to learn a little bit more.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12314&group=comp.lang.tcl#12314

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:15b:b0:777:6c57:156 with SMTP id e27-20020a05620a015b00b007776c570156mr212666qkn.8.1698180840652;
Tue, 24 Oct 2023 13:54:00 -0700 (PDT)
X-Received: by 2002:a05:6830:1d91:b0:6c4:d19b:dabd with SMTP id
y17-20020a0568301d9100b006c4d19bdabdmr3860573oti.1.1698180840356; Tue, 24 Oct
2023 13:54:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 24 Oct 2023 13:53:59 -0700 (PDT)
In-Reply-To: <87bkcpgi1k.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:ee:9704:9e00:d48a:9b9e:8ba4:b51b;
posting-account=IpC1pwoAAACCAmF-qbg4PWxvUAd-j7Tc
NNTP-Posting-Host: 2003:ee:9704:9e00:d48a:9b9e:8ba4:b51b
References: <87bkcpgi1k.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
Subject: Re: Substituting variable
From: molecool...@googlemail.com (Mole Cool)
Injection-Date: Tue, 24 Oct 2023 20:54:00 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2007
 by: Mole Cool - Tue, 24 Oct 2023 20:53 UTC

Cecil Westerhof schrieb am Montag, 23. Oktober 2023 um 23:14:08 UTC+2:
> I have the following code:
> set selectWeek {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo >= ${startWeek}
> AND WeekNo <= ${endWeek}
> GROUP BY WeekNo
> ORDER BY WeekNo
> }
>
> Only later the values for startWeek and endWeek are determined. When
> they are determined, is there a possibility to have the right values
> substituted, or should I work with format?
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Maybe to stupid, but why you don’t use quotes for your sql statement?

Re: Substituting variable

<uhafkd$jht1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12315&group=comp.lang.tcl#12315

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortka...@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 09:20:45 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <uhafkd$jht1$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl>
<c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 25 Oct 2023 07:20:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="168524e0a236168f575757eeca375b62";
logging-data="640929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ayT6cx3a6FwrBPDEYvFrc"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NK2usRW6vzBukYWOUM0dhjum29A=
Content-Language: en-GB
In-Reply-To: <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
 by: Harald Oehlmann - Wed, 25 Oct 2023 07:20 UTC

Am 24.10.2023 um 22:53 schrieb Mole Cool:
> Cecil Westerhof schrieb am Montag, 23. Oktober 2023 um 23:14:08 UTC+2:
>> I have the following code:
>> set selectWeek {
>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> , SUM(dayViews) AS WeekTotals
>> FROM dayViews
>> WHERE WeekNo >= ${startWeek}
>> AND WeekNo <= ${endWeek}
>> GROUP BY WeekNo
>> ORDER BY WeekNo
>> }
>>
>> Only later the values for startWeek and endWeek are determined. When
>> they are determined, is there a possibility to have the right values
>> substituted, or should I work with format?
>>
>> --
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>
>
> Maybe to stupid, but why you don’t use quotes for your sql statement?

If your variable data contains quotes, it must be handled.
That is, how SQL Injection attacks work.

"select * from table where CustID = '$CustId'"

Then, CustId comes from a web server and contains "q'; delete table;
select '"
and you get executed:
"select * from table where CustID = 'q'; delete table; select ''"

To avoid this, use the ":" syntax. It cares about correct quoting.

Take care,
Harald

Re: Substituting variable

<87y1frf27e.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12316&group=comp.lang.tcl#12316

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 12:04:05 +0200
Organization: Decebal Computing
Lines: 37
Message-ID: <87y1frf27e.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl>
<c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="3b6013747b80a2adb2e2e187834ffdef";
logging-data="735211"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18I3aKFhURHCqnKJtSYNs5zWDqha6gvHYw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:vHdo263kdWHHCeVF3F1w9NLYaPM=
sha1:FwAHlm8vLFGsoaY+brDpuGURN00=
 by: Cecil Westerhof - Wed, 25 Oct 2023 10:04 UTC

Mole Cool <molecool1058@googlemail.com> writes:

> Cecil Westerhof schrieb am Montag, 23. Oktober 2023 um 23:14:08 UTC+2:
>> I have the following code:
>> set selectWeek {
>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> , SUM(dayViews) AS WeekTotals
>> FROM dayViews
>> WHERE WeekNo >= ${startWeek}
>> AND WeekNo <= ${endWeek}
>> GROUP BY WeekNo
>> ORDER BY WeekNo
>> }
>>
>> Only later the values for startWeek and endWeek are determined. When
>> they are determined, is there a possibility to have the right values
>> substituted, or should I work with format?
>>
>> --
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>
>
> Maybe to stupid, but why you don’t use quotes for your sql statement?

That is not going to work, because the variables do not exist yet, so
I will get:
WHERE WeekNo >=
AND WeekNo <=

That is not going to do what I want.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<651c561b-c8c5-40da-8cb4-73851f431736n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12317&group=comp.lang.tcl#12317

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:4a48:b0:66d:17f:4dd2 with SMTP id ph8-20020a0562144a4800b0066d017f4dd2mr243493qvb.2.1698235183919;
Wed, 25 Oct 2023 04:59:43 -0700 (PDT)
X-Received: by 2002:a05:6870:1684:b0:1e1:40df:f0d1 with SMTP id
j4-20020a056870168400b001e140dff0d1mr6823058oae.11.1698235183643; Wed, 25 Oct
2023 04:59:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 25 Oct 2023 04:59:43 -0700 (PDT)
In-Reply-To: <87y1frf27e.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=212.243.175.74; posting-account=cY1uRgoAAAD1PpfCHRSABChlMQs7_rU7
NNTP-Posting-Host: 212.243.175.74
References: <87bkcpgi1k.fsf@munus.decebal.nl> <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
<87y1frf27e.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <651c561b-c8c5-40da-8cb4-73851f431736n@googlegroups.com>
Subject: Re: Substituting variable
From: r.zaums...@gmail.com (rene)
Injection-Date: Wed, 25 Oct 2023 11:59:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2601
 by: rene - Wed, 25 Oct 2023 11:59 UTC

Cecil Westerhof schrieb am Mittwoch, 25. Oktober 2023 um 12:14:08 UTC+2:
> Mole Cool <moleco...@googlemail.com> writes:
>
> > Cecil Westerhof schrieb am Montag, 23. Oktober 2023 um 23:14:08 UTC+2:
> >> I have the following code:
> >> set selectWeek {
> >> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> >> , SUM(dayViews) AS WeekTotals
> >> FROM dayViews
> >> WHERE WeekNo >= ${startWeek}
> >> AND WeekNo <= ${endWeek}
> >> GROUP BY WeekNo
> >> ORDER BY WeekNo
> >> }
> >>
> >> Only later the values for startWeek and endWeek are determined. When
> >> they are determined, is there a possibility to have the right values
> >> substituted, or should I work with format?
> >>
> >> --
> >> Cecil Westerhof
> >> Senior Software Engineer
> >> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> >
> >
> > Maybe to stupid, but why you don’t use quotes for your sql statement?
> That is not going to work, because the variables do not exist yet, so
> I will get:
> WHERE WeekNo >=
> AND WeekNo <=
>
> That is not going to do what I want.
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

You should put the query in braces like {select ... where WeekNo >= $weekno}

HTH
rene

Re: Substituting variable

<yga4jie7nxv.fsf@panther.akutech-local.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12318&group=comp.lang.tcl#12318

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 16:54:04 +0200
Lines: 28
Message-ID: <yga4jie7nxv.fsf@panther.akutech-local.de>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net oDcU2yhI2Ha35K139b/JFwusrefXy8p7FWiXf9roXyz//Cx0o=
Cancel-Lock: sha1:18mA+jWtMMnzNun4TTtLOBZRIt4= sha1:Sk15TnEVqnXeU39kC6B3/keM66U= sha256:ykyZwGQM6KpWmCBW1F1lLQNKg+kQkf9vgfT01A1ClUE=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Wed, 25 Oct 2023 14:54 UTC

* Rich <rich@example.invalid>
| Cecil Westerhof <Cecil@decebal.nl> wrote:
| > Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
| >> How are you executing the SQL?
| >
| > 'package require sqlite3' and 'db eval …'
| >
| >> If you're using tdbc, then you can, and should, change your WHERE
| >> clause to
| >>
| >> WHERE WeekNo >= :startWeek
| >> AND WeekNo <= :endWeek
| >
| > That was it. I knew it could be done, but did not remember how.
>
| Sqlite's Tcl API supports three different ways to "substitute" (which
| one to use depends upon exactly what it is that is in the variable).
>
| The docs at: https://sqlite.org/tclsqlite.html explain all three in the
| description of the "eval" method.

These docs state that
db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
and
db1 eval {INSERT INTO t1 VALUES(5,$bigstring)}
are equivalent, so I wonder why the original approach did not work?

R'

Re: Substituting variable

<a58117a2-6b21-4f48-8456-0f9e85aa86c5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12319&group=comp.lang.tcl#12319

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:1490:b0:774:c52:737 with SMTP id w16-20020a05620a149000b007740c520737mr257584qkj.11.1698248605991;
Wed, 25 Oct 2023 08:43:25 -0700 (PDT)
X-Received: by 2002:a05:6808:2190:b0:3b2:e15d:e560 with SMTP id
be16-20020a056808219000b003b2e15de560mr5844209oib.9.1698248605796; Wed, 25
Oct 2023 08:43:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 25 Oct 2023 08:43:25 -0700 (PDT)
In-Reply-To: <yga4jie7nxv.fsf@panther.akutech-local.de>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.33; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.33
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me> <yga4jie7nxv.fsf@panther.akutech-local.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a58117a2-6b21-4f48-8456-0f9e85aa86c5n@googlegroups.com>
Subject: Re: Substituting variable
From: gregor.e...@googlemail.com (greg)
Injection-Date: Wed, 25 Oct 2023 15:43:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 86
 by: greg - Wed, 25 Oct 2023 15:43 UTC

package req sqlite3
sqlite3 db :memory:

proc sqlTolist {db sqltext} {
db eval $sqltext value {
set row [list]
foreach col $value(*) {
lappend row $value($col)
}
lappend rows $row
}
set rows [linsert $rows 0 $value(*)]
return $rows
}

proc sqlWbindTolist {db sqltext startWeek endWeek} {
db eval $sqltext value {
set row [list]
foreach col $value(*) {
lappend row $value($col)
}
lappend rows $row
}
set rows [linsert $rows 0 $value(*)]
return $rows
}

set sqltext {
CREATE TABLE dayViews (
dayDate TEXT NOT NULL DEFAULT (date('now', '-1 day')),
dayViews INTEGER NOT NULL,
PRIMARY KEY(dayDate)
)
;}
db eval $sqltext

#Testdata
proc testdata {{days 30}} {
set sDate [clock add [clock scan now] -$days day]
for {set i 0 } { $i < [expr {2 * $days }]} { incr i } {
lappend r [list [clock format [clock add $sDate $i day ] -format "%Y-%m-%d" ] 10]
}
return $r
} set sqltext {INSERT INTO dayViews VALUES(:dayDate,:dayViews)}
foreach a [testdata] {
set dayDate [lindex $a 0]
set dayViews [lindex $a 1]
db eval $sqltext
}

set sqltext {
SELECT MIN(WeekNo), MAX(WeekNo) FROM (
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, COUNT(dayViews) AS Days
FROM dayViews
GROUP BY WeekNo
)
WHERE Days = 7
;}
puts "1. $sqltext\n [sqlTolist db $sqltext]"

set sqltext {
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, SUM(dayViews) AS WeekTotals
FROM dayViews
WHERE WeekNo >= :startWeek
AND WeekNo <= :endWeek
GROUP BY WeekNo
ORDER BY WeekNo
;}
puts "2. $sqltext\n [sqlWbindTolist db $sqltext 40 43]"

set sqltext {
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, COUNT(dayViews) AS Days
FROM dayViews
GROUP BY WeekNo
;}
puts "3. $sqltext\n [sqlTolist db $sqltext]"

set sqltext {
select *
FROM dayViews
;}
puts "4. $sqltext\n [sqlTolist db $sqltext]"

Re: Substituting variable

<uhbf6u$s72q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12320&group=comp.lang.tcl#12320

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam.n...@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 17:19:25 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <uhbf6u$s72q$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 25 Oct 2023 16:19:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a3490fbd156dc9496b9563fddafe1eb7";
logging-data="924762"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/71UZcOD281uDGWEahT9Ap4W/6zawxgf4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:E7s8Xe8iVrAVxo1vjWrmoSoS6DQ=
In-Reply-To: <877cncgl6r.fsf@munus.decebal.nl>
Content-Language: en-US
 by: Alan Grunwald - Wed, 25 Oct 2023 16:19 UTC

On 24/10/2023 15:16, Cecil Westerhof wrote:
> Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
>

Big snip

>> IMHO, If you aren't using tdbc, then you should be.
>
> I am not using tdbc. What are the advantages of it?
>

I wasn't aware of how to handle variable substitution using the sqlite
package; I guess that when I was using (before I discovered tdbc) I
didn't understand the security risks of constructing SQL text that
includes user-supplied values - referred to later in this thread.

To my mind the main point of using tdbc is that it's fairly agnostic
about the underlying database, so that if one day I need to switch my
code from running over sqlite to running over, say, MySQL I only (!?)
need to worry about inconsistencies in the SQL dialect; everything else
"just works" after I change the TCL command used to create the database
connection.

Alan

Re: Substituting variable

<87ttqefydl.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12321&group=comp.lang.tcl#12321

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 18:41:26 +0200
Organization: Decebal Computing
Lines: 36
Message-ID: <87ttqefydl.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="3b6013747b80a2adb2e2e187834ffdef";
logging-data="937752"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QkiWO4LbgKsfdR4sIEGiCTl216MnImEw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:ht9zTLe/49OKlMfE05I9LHTiJ68=
sha1:EH7hlJs2kujdQAryun6aY/QOWTU=
 by: Cecil Westerhof - Wed, 25 Oct 2023 16:41 UTC

Ralf Fassel <ralfixx@gmx.de> writes:

> * Rich <rich@example.invalid>
> | Cecil Westerhof <Cecil@decebal.nl> wrote:
> | > Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
> | >> How are you executing the SQL?
> | >
> | > 'package require sqlite3' and 'db eval …'
> | >
> | >> If you're using tdbc, then you can, and should, change your WHERE
> | >> clause to
> | >>
> | >> WHERE WeekNo >= :startWeek
> | >> AND WeekNo <= :endWeek
> | >
> | > That was it. I knew it could be done, but did not remember how.
>>
> | Sqlite's Tcl API supports three different ways to "substitute" (which
> | one to use depends upon exactly what it is that is in the variable).
>>
> | The docs at: https://sqlite.org/tclsqlite.html explain all three in the
> | description of the "eval" method.
>
> These docs state that
> db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
> and
> db1 eval {INSERT INTO t1 VALUES(5,$bigstring)}
> are equivalent, so I wonder why the original approach did not work?

Because I do not use a 'local' list, but a 'global' string variable:
db1 eval ${commandStr}

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<335f0677-cc47-40ac-be95-140421c53771n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12322&group=comp.lang.tcl#12322

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:2042:b0:774:1eb5:d6a8 with SMTP id d2-20020a05620a204200b007741eb5d6a8mr253985qka.9.1698252444333;
Wed, 25 Oct 2023 09:47:24 -0700 (PDT)
X-Received: by 2002:a05:6870:15cf:b0:1e9:adc3:c31c with SMTP id
k15-20020a05687015cf00b001e9adc3c31cmr6945705oad.0.1698252444055; Wed, 25 Oct
2023 09:47:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 25 Oct 2023 09:47:23 -0700 (PDT)
In-Reply-To: <a58117a2-6b21-4f48-8456-0f9e85aa86c5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.33; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.33
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de> <a58117a2-6b21-4f48-8456-0f9e85aa86c5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <335f0677-cc47-40ac-be95-140421c53771n@googlegroups.com>
Subject: Re: Substituting variable
From: gregor.e...@googlemail.com (greg)
Injection-Date: Wed, 25 Oct 2023 16:47:24 +0000
Content-Type: text/plain; charset="UTF-8"
 by: greg - Wed, 25 Oct 2023 16:47 UTC

greg schrieb am Mittwoch, 25. Oktober 2023 um 17:43:29 UTC+2:
> package req sqlite3
> sqlite3 db :memory:
>
> proc sqlTolist {db sqltext} {
> db eval $sqltext value {
> set row [list]
> foreach col $value(*) {
> lappend row $value($col)
> }
> lappend rows $row
> }
> set rows [linsert $rows 0 $value(*)]
> return $rows
> }
>
> proc sqlWbindTolist {db sqltext startWeek endWeek} {
> db eval $sqltext value {
> set row [list]
> foreach col $value(*) {
> lappend row $value($col)
> }
> lappend rows $row
> }
> set rows [linsert $rows 0 $value(*)]
> return $rows
> }
>

#bug in procs $db

proc sqlTolist {db sqltext} {
$db eval $sqltext value {
set row [list]
foreach col $value(*) {
lappend row $value($col)
}
lappend rows $row
}
set rows [linsert $rows 0 $value(*)]
return $rows
}

proc sqlWbindTolist {db sqltext startWeek endWeek} {
$db eval $sqltext value {
set row [list]
foreach col $value(*) {
lappend row $value($col)
}
lappend rows $row
}
set rows [linsert $rows 0 $value(*)]
return $rows
}

# this proc replaced proc sqlWbindTolist
proc sqlTolist {db sqltext args} {
if {[llength $args] != "0" && ([llength $args] %2) == 0} {
dict for {k v } $args {set $k $v}
} elseif {([llength $args] %2) != 0} {
puts "Bind Error args: $args"
return error
}
$db eval $sqltext value {
set row [list]
foreach col $value(*) {
lappend row $value($col)
}
lappend rows $row
}
set rows [linsert $rows 0 $value(*)]
return $rows
}

#But tdbc is much better

Re: Substituting variable

<87pm12fy84.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12323&group=comp.lang.tcl#12323

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 18:44:43 +0200
Organization: Decebal Computing
Lines: 49
Message-ID: <87pm12fy84.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl>
<c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
<87y1frf27e.fsf@munus.decebal.nl>
<651c561b-c8c5-40da-8cb4-73851f431736n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="3b6013747b80a2adb2e2e187834ffdef";
logging-data="945916"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LoWwZIuD6DV3kUou8Jg47i33FXpu8Ghk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:wwY7s0gcrrrKKtsnO5GgMyGzjLA=
sha1:1eS22JVX6oBtT63GUi/PRLRMPMg=
 by: Cecil Westerhof - Wed, 25 Oct 2023 16:44 UTC

rene <r.zaumseil@gmail.com> writes:

> Cecil Westerhof schrieb am Mittwoch, 25. Oktober 2023 um 12:14:08 UTC+2:
>> Mole Cool <moleco...@googlemail.com> writes:
>>
>> > Cecil Westerhof schrieb am Montag, 23. Oktober 2023 um 23:14:08 UTC+2:
>> >> I have the following code:
>> >> set selectWeek {
>> >> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> >> , SUM(dayViews) AS WeekTotals
>> >> FROM dayViews
>> >> WHERE WeekNo >= ${startWeek}
>> >> AND WeekNo <= ${endWeek}
>> >> GROUP BY WeekNo
>> >> ORDER BY WeekNo
>> >> }
>> >>
>> >> Only later the values for startWeek and endWeek are determined. When
>> >> they are determined, is there a possibility to have the right values
>> >> substituted, or should I work with format?
>> >>
>> >> --
>> >> Cecil Westerhof
>> >> Senior Software Engineer
>> >> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>> >
>> >
>> > Maybe to stupid, but why you don’t use quotes for your sql statement?
>> That is not going to work, because the variables do not exist yet, so
>> I will get:
>> WHERE WeekNo >=
>> AND WeekNo <=
>>
>> That is not going to do what I want.
>> --
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>
> You should put the query in braces like {select ... where WeekNo >= $weekno}

I already tried that (before asking here), but that does not work.

But it is solved by using :startWeek and :endWeek.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12324&group=comp.lang.tcl#12324

  copy link   Newsgroups: comp.lang.tcl
Date: Wed, 25 Oct 2023 21:04:04 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Substituting variable
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <yga4jie7nxv.fsf@panther.akutech-local.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 12
Injection-Date: Wed, 25 Oct 2023 21:04:04 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Schelte - Wed, 25 Oct 2023 19:04 UTC

On 25/10/2023 16:54, Ralf Fassel wrote:
> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)} and
> db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so I
> wonder why the original approach did not work?

Because the OP insists on writing his variables as ${startWeek} etc. Had
he used $startWeek, it would have worked.

Schelte.

Re: Substituting variable

<87lebqfrs0.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12325&group=comp.lang.tcl#12325

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Wed, 25 Oct 2023 21:03:59 +0200
Organization: Decebal Computing
Lines: 31
Message-ID: <87lebqfrs0.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uhbf6u$s72q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="3b6013747b80a2adb2e2e187834ffdef";
logging-data="1024320"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mXlhOFLGugh8Vsm8Rn/EW/OoiI0nnEfo="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:RvMs99VbjiDIFBaVQ2Orv5t/MSY=
sha1:zTrKxaGq2BK3XvD9D/kd7kMATg4=
 by: Cecil Westerhof - Wed, 25 Oct 2023 19:03 UTC

Alan Grunwald <nospam.nurdglaw@gmail.com> writes:

> On 24/10/2023 15:16, Cecil Westerhof wrote:
>> Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
>>
>
> Big snip
>
>>> IMHO, If you aren't using tdbc, then you should be.
>> I am not using tdbc. What are the advantages of it?
>>
>
> I wasn't aware of how to handle variable substitution using the sqlite
> package; I guess that when I was using (before I discovered tdbc) I
> didn't understand the security risks of constructing SQL text that
> includes user-supplied values - referred to later in this thread.
>
> To my mind the main point of using tdbc is that it's fairly agnostic
> about the underlying database, so that if one day I need to switch my
> code from running over sqlite to running over, say, MySQL I only (!?)
> need to worry about inconsistencies in the SQL dialect; everything else
> "just works" after I change the TCL command used to create the database
> connection.

It is almost impossible that I will something else as SQLite.
(In this case anyway.)

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<87h6mefhv9.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12326&group=comp.lang.tcl#12326

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Thu, 26 Oct 2023 00:38:02 +0200
Organization: Decebal Computing
Lines: 18
Message-ID: <87h6mefhv9.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="a8a6a3348a36ae84d8a380c80d6127c3";
logging-data="1144006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+alkDAlzbkcbSwQPbH/LscvO9PzLz5X0I="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:/r5juKXzrWVn2ng1MOrQHIFRDZk=
sha1:jRPPeoejVMwwOMFgUJiRPhRLQGM=
 by: Cecil Westerhof - Wed, 25 Oct 2023 22:38 UTC

Schelte <nospam@wanadoo.nl> writes:

> On 25/10/2023 16:54, Ralf Fassel wrote:
>> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
>> and db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so
>> I wonder why the original approach did not work?
>
> Because the OP insists on writing his variables as ${startWeek} etc. Had
> he used $startWeek, it would have worked.

You do not know what you are talking about, that is completely b***t.
You may not like how I write my variables, but that does not mean it
is wrong.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<nnd$101f2398$4d7314fd@81103b44e3b0661b>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12327&group=comp.lang.tcl#12327

  copy link   Newsgroups: comp.lang.tcl
Date: Thu, 26 Oct 2023 00:55:05 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Substituting variable
Content-Language: nl-NL, en-US
Newsgroups: comp.lang.tcl
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b> <87h6mefhv9.fsf@munus.decebal.nl>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <87h6mefhv9.fsf@munus.decebal.nl>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$101f2398$4d7314fd@81103b44e3b0661b>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 22
Injection-Date: Thu, 26 Oct 2023 00:55:05 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1690
 by: Schelte - Wed, 25 Oct 2023 22:55 UTC

On 26/10/2023 00:38, Cecil Westerhof wrote:
> Schelte <nospam@wanadoo.nl> writes:
>
>> On 25/10/2023 16:54, Ralf Fassel wrote:
>>> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
>>> and db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so
>>> I wonder why the original approach did not work?
>>
>> Because the OP insists on writing his variables as ${startWeek} etc. Had
>> he used $startWeek, it would have worked.
>
> You do not know what you are talking about, that is completely b***t.
> You may not like how I write my variables, but that does not mean it
> is wrong.
>
It is wrong if you want sqlite to replace the variables. It only handles
$variable, :variable, and @variable. Not ${variable}.

Schelte.

Re: Substituting variable

<87cyx2fdcv.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12328&group=comp.lang.tcl#12328

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Thu, 26 Oct 2023 02:15:28 +0200
Organization: Decebal Computing
Lines: 30
Message-ID: <87cyx2fdcv.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b> <87h6mefhv9.fsf@munus.decebal.nl>
<nnd$101f2398$4d7314fd@81103b44e3b0661b>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="a8a6a3348a36ae84d8a380c80d6127c3";
logging-data="1194754"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+klEKP8YKHmmiCMjzLFHUBuwEB3YZHCyo="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:EF7iQr7WDycBN/dVUBCthF2i1LM=
sha1:7JPCtTgYTRdfo5NaCDccdYX5aEk=
 by: Cecil Westerhof - Thu, 26 Oct 2023 00:15 UTC

Schelte <nospam@wanadoo.nl> writes:

> On 26/10/2023 00:38, Cecil Westerhof wrote:
>> Schelte <nospam@wanadoo.nl> writes:
>>
>>> On 25/10/2023 16:54, Ralf Fassel wrote:
>>>> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
>>>> and db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so
>>>> I wonder why the original approach did not work?
>>>
>>> Because the OP insists on writing his variables as ${startWeek} etc. Had
>>> he used $startWeek, it would have worked.
>> You do not know what you are talking about, that is completely b***t.
>> You may not like how I write my variables, but that does not mean it
>> is wrong.
>>
> It is wrong if you want sqlite to replace the variables. It only handles
> $variable, :variable, and @variable. Not ${variable}.

That works if you use it as a 'local' list, but that is not what I am
doing. I have the query in a variable and use:
db eval ${sqlCommand}

Then $variable does not work, but :variable does.
And at the same time it is secure.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<87r0li87i0.fsf@pointsman.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12329&group=comp.lang.tcl#12329

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rol...@pointsman.de (Rolf Ade)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Thu, 26 Oct 2023 04:03:51 +0200
Organization: Me
Lines: 43
Message-ID: <87r0li87i0.fsf@pointsman.de>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>
<87h6mefhv9.fsf@munus.decebal.nl>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net zfBOL7FuHPiK1is0K+fowg8jZtIdukhHJYFSh4Z9CTlXgMUwQ=
Cancel-Lock: sha1:zo5mAbFbZb8UbtzFXHhklkfoclk= sha1:imx7GNWUd4NfeS2jRDxd7GwtTdU= sha256:6hiJwhkPLSri8Y6MLWr6V5sdDUgpCUm4Mop0S213s68=
User-Agent: Gnus/5.13 (Gnus v5.13)
 by: Rolf Ade - Thu, 26 Oct 2023 02:03 UTC

Cecil Westerhof <Cecil@decebal.nl> writes:
> Schelte <nospam@wanadoo.nl> writes:
>
>> On 25/10/2023 16:54, Ralf Fassel wrote:
>>> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
>>> and db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so
>>> I wonder why the original approach did not work?
>>
>> Because the OP insists on writing his variables as ${startWeek} etc. Had
>> he used $startWeek, it would have worked.
>
> You do not know what you are talking about, that is completely b***t.
> You may not like how I write my variables, but that does not mean it
> is wrong.

No reason for strong words. Schelte is right that your habit to write
variable references as ${startWeek} is your problem here. See this code:

package require sqlite3

sqlite3 db :memory:

db eval {
CREATE TABLE something(key text, value text);
INSERT INTO something(key, value)
VALUES('foo', 'foovalue');
INSERT INTO something(key, value)
VALUES('bar', 'barvalue')
}

set thiskey "bar"
puts [db eval {
SELECT value FROM something
WHERE key = $thiskey
}]
catch {db eval {
SELECT value FROM something
WHERE key = ${thiskey}
}} errMsg
puts $errMsg

Re: Substituting variable

<3a878761-bdf1-476b-90a6-eeea1cd67a34n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12330&group=comp.lang.tcl#12330

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ae9:e201:0:b0:772:5d97:4246 with SMTP id c1-20020ae9e201000000b007725d974246mr341104qkc.10.1698298442420;
Wed, 25 Oct 2023 22:34:02 -0700 (PDT)
X-Received: by 2002:a05:6870:1684:b0:1e1:40df:f0d1 with SMTP id
j4-20020a056870168400b001e140dff0d1mr7785355oae.11.1698298441976; Wed, 25 Oct
2023 22:34:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 25 Oct 2023 22:34:01 -0700 (PDT)
In-Reply-To: <87r0li87i0.fsf@pointsman.de>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.59; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.59
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de> <nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>
<87h6mefhv9.fsf@munus.decebal.nl> <87r0li87i0.fsf@pointsman.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3a878761-bdf1-476b-90a6-eeea1cd67a34n@googlegroups.com>
Subject: Re: Substituting variable
From: gregor.e...@googlemail.com (greg)
Injection-Date: Thu, 26 Oct 2023 05:34:02 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2191
 by: greg - Thu, 26 Oct 2023 05:34 UTC

#difference variable and array
# dbcmd eval ?-withoutnulls? sql ?array-name? ?script?

set a 0
set {a} 2

set value(a) 3
set value({a}) 4

puts "[tcl::unsupported::representation $a]"
puts "[tcl::unsupported::representation ${a}]"
puts "[tcl::unsupported::representation $value(a)]"
puts "[tcl::unsupported::representation $value({a})]"

puts $a
puts ${a}

parray value

if {0} {
value is a pure string with a refcount of 2, object pointer at 0x55fe45c14160, string representation "2"
value is a pure string with a refcount of 2, object pointer at 0x55fe45c14160, string representation "2"
value is a pure string with a refcount of 2, object pointer at 0x55fe45c14190, string representation "3"
value is a pure string with a refcount of 2, object pointer at 0x55fe45c14100, string representation "4"
2 2
value(a) = 3
value({a}) = 4

}

Re: Substituting variable

<nnd$52cd8167$44118e18@a32f859438f3006c>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12331&group=comp.lang.tcl#12331

  copy link   Newsgroups: comp.lang.tcl
Date: Thu, 26 Oct 2023 10:18:00 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Substituting variable
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me> <877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me> <yga4jie7nxv.fsf@panther.akutech-local.de> <nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b> <87h6mefhv9.fsf@munus.decebal.nl> <nnd$101f2398$4d7314fd@81103b44e3b0661b> <87cyx2fdcv.fsf@munus.decebal.nl>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <87cyx2fdcv.fsf@munus.decebal.nl>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$52cd8167$44118e18@a32f859438f3006c>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tr3.iad1.usenetexpress.com!feeder.usenetexpress.com!tr1.eu1.usenetexpress.com!94.232.112.244.MISMATCH!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 33
Injection-Date: Thu, 26 Oct 2023 10:18:00 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Schelte - Thu, 26 Oct 2023 08:18 UTC

On 26/10/2023 02:15, Cecil Westerhof wrote:
> That works if you use it as a 'local' list, but that is not what I am
> doing. I have the query in a variable and use:
> db eval ${sqlCommand}
>
> Then $variable does not work, but :variable does.
> And at the same time it is secure.
>
As Rolf mentioned, :variable and $variable are equivalent in sqlite. So
everywhere where substitution of :variable works, $variable will also work:

% package require sqlite3
3.39.3
% sqlite3 db :memory:
% set sqlCommand1 {select :variable}
select :variable
% set sqlCommand2 {select $variable}
select $variable
% set sqlCommand3 {select ${variable}}
select ${variable}
% set variable bla
bla
% db eval ${sqlCommand1}
bla
% db eval ${sqlCommand2}
bla
% db eval ${sqlCommand3}
unrecognized token: "$"

Schelte

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor