zope.app.sqlscript 3.5.0
pip install zope.app.sqlscript
Released:
SQL Script -- Zope 3 Content Component
Navigation
Verified details
These details have been verified by PyPIOwner
Maintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Zope Public License (ZPL 2.1)
- Author: Zope Corporation and Contributors
- Tags zope3, sql, script
Classifiers
- Development Status
- Environment
- Framework
- Intended Audience
- License
- Natural Language
- Operating System
- Programming Language
- Topic
Project description
This package provides the SQL Script content type for Zope 3 applications. SQL Scripts are connected to execute SQL statements and the result is return in an object-oriented data structure.
Detailed Documentation
Using additional DTML tags in SQLScript
Inserting optional tests with ‘sqlgroup’
It is sometimes useful to make inputs to an SQL statement optinal. Doing so can be difficult, because not only must the test be inserted conditionally, but SQL boolean operators may or may not need to be inserted depending on whether other, possibly optional, comparisons have been done. The ‘sqlgroup’ tag automates the conditional insertion of boolean operators.
The ‘sqlgroup’ tag is a block tag that has no attributes. It can have any number of ‘and’ and ‘or’ continuation tags.
Suppose we want to find all people with a given first or nick name and optionally constrain the search by city and minimum and maximum age. Suppose we want all inputs to be optional. We can use DTML source like the following:
<dtml-sqlgroup> <dtml-sqlgroup> <dtml-sqltest name column=nick_name type=nb multiple optional> <dtml-or> <dtml-sqltest name column=first_name type=nb multiple optional> </dtml-sqlgroup> <dtml-and> <dtml-sqltest home_town type=nb optional> <dtml-and> <dtml-if minimum_age> age >= <dtml-sqlvar minimum_age type=int> </dtml-if> <dtml-and> <dtml-if maximum_age> age <= <dtml-sqlvar maximum_age type=int> </dtml-if> </dtml-sqlgroup>
This example illustrates how groups can be nested to control boolean evaluation order. It also illustrates that the grouping facility can also be used with other DTML tags like ‘if’ tags.
The ‘sqlgroup’ tag checks to see if text to be inserted contains other than whitespace characters. If it does, then it is inserted with the appropriate boolean operator, as indicated by use of an ‘and’ or ‘or’ tag, otherwise, no text is inserted.
Inserting optional tests with ‘sqlgroup’
It is sometimes useful to make inputs to an SQL statement optinal. Doing so can be difficult, because not only must the test be inserted conditionally, but SQL boolean operators may or may not need to be inserted depending on whether other, possibly optional, comparisons have been done. The ‘sqlgroup’ tag automates the conditional insertion of boolean operators.
The ‘sqlgroup’ tag is a block tag. It can have any number of ‘and’ and ‘or’ continuation tags.
The ‘sqlgroup’ tag has an optional attribure, ‘required’ to specify groups that must include at least one test. This is useful when you want to make sure that a query is qualified, but want to be very flexible about how it is qualified.
Suppose we want to find people with a given first or nick name, city or minimum and maximum age. Suppose we want all inputs to be optional, but want to require some input. We can use DTML source like the following:
<dtml-sqlgroup required> <dtml-sqlgroup> <dtml-sqltest name column=nick_name type=nb multiple optional> <dtml-or> <dtml-sqltest name column=first_name type=nb multiple optional> </dtml-sqlgroup> <dtml-and> <dtml-sqltest home_town type=nb optional> <dtml-and> <dtml-if minimum_age> age >= <dtml-sqlvar minimum_age type=int> </dtml-if> <dtml-and> <dtml-if maximum_age> age <= <dtml-sqlvar maximum_age type=int> </dtml-if> </dtml-sqlgroup>
This example illustrates how groups can be nested to control boolean evaluation order. It also illustrates that the grouping facility can also be used with other DTML tags like ‘if’ tags.
The ‘sqlgroup’ tag checks to see if text to be inserted contains other than whitespace characters. If it does, then it is inserted with the appropriate boolean operator, as indicated by use of an ‘and’ or ‘or’ tag, otherwise, no text is inserted.
Inserting values with the ‘sqlvar’ tag
The ‘sqlvar’ tag is used to type-safely insert values into SQL text. The ‘sqlvar’ tag is similar to the ‘var’ tag, except that it replaces text formatting parameters with SQL type information.
The sqlvar tag has the following attributes:
- name
The name of the variable to insert. As with other DTML tags, the ‘name=’ prefix may be, and usually is, ommitted.
- type
The data type of the value to be inserted. This attribute is required and may be one of ‘string’, ‘int’, ‘float’, or ‘nb’. The ‘nb’ data type indicates a string that must have a length that is greater than 0.
- optional
A flag indicating that a value is optional. If a value is optional and is not provided (or is blank when a non-blank value is expected), then the string ‘null’ is inserted.
For example, given the tag:
<dtml-sqlvar x type=nb optional>
if the value of ‘x’ is:
Let\'s do it
then the text inserted is:
‘Let’’s do it’
however, if x is ommitted or an empty string, then the value inserted is ‘null’.
CHANGES
3.5.0 (2009-02-01)
Use zope.container instead of zope.app.container.
3.4.1 (2007-10-31)
Resolve ZopeSecurityPolicy deprecation warning.
3.4.0 (2007-10-27)
Initial release independent of the main Zope tree.
Project details
Verified details
These details have been verified by PyPIOwner
Maintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Zope Public License (ZPL 2.1)
- Author: Zope Corporation and Contributors
- Tags zope3, sql, script
Classifiers
- Development Status
- Environment
- Framework
- Intended Audience
- License
- Natural Language
- Operating System
- Programming Language
- Topic
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file zope.app.sqlscript-3.5.0.tar.gz
.
File metadata
- Download URL: zope.app.sqlscript-3.5.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8abaae3ab930a6962f89629729017f900192b30f952ff4fa5af9cadfb65e9b71 |
|
MD5 | 657aab7dbb07f157aa8ab1e3177be49a |
|
BLAKE2b-256 | f6cd3b0f5bce73fa938cdf6fedcc2e23eedf8a48147156dd8d1e62cd455aa5a5 |