Skip to content

Commit 4dfabf3

Browse files
committed
add additional sqlalchemy coding examples and new descriptions for flask examples
1 parent e0ce2ac commit 4dfabf3

File tree

143 files changed

+2774
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2774
-253
lines changed

content/pages/04-web-development/15-web-design.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ this short list as my absolute favorites that help developers become
113113
examples and further details for the four principles, which are contrast,
114114
consistency, Occam's Razor and space.
115115

116+
* [Gallery of web design history](https://www.webdesignmuseum.org/gallery) is
117+
a collection of websites from between 1991 and 2006 that show the evolution
118+
of what the web looked like before the modern
119+
[CSS](/cascading-style-sheets.html) era. This is a great resource to see
120+
how websites evolved, such as
121+
[Microsoft in 1996](https://www.webdesignmuseum.org/gallery/microsoft-1996)
122+
and [YouTube in 2005](https://www.webdesignmuseum.org/gallery/youtube-2005).
123+
116124
* [The Average Web Page (Data from Analyzing 8 Million Websites)](https://css-tricks.com/average-web-page-data-analyzing-8-million-websites/)
117125
shows the most frequently used HTML elements, metadata, text
118126
content and other statistics from a large scale analysis of the web.

content/pages/examples/flask/flask-app-immutabledict.markdown

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ sidebartitle: flask.app ImmutableDict
77
meta: Example code for understanding how to use the ImmutableDict class from the flask.app module of the Flask project.
88

99

10-
ImmutableDict is a class within the flask.app module of the Flask project.
10+
[ImmutableDict](https://github.com/pallets/flask/blob/master/src/flask/app.py)
11+
is a class within the flask.app module of the [Flask](/flask.html)
12+
framework that is actually imported from the Werkzeug
13+
[datastructures module](https://github.com/pallets/werkzeug/blob/master/src/werkzeug/datastructures.py).
14+
The ImmutableDict class wraps a
15+
[standard Python dictionary](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)
16+
so that values cannot be modified after initially being set.
1117

1218

1319
## Example 1 from indico

content/pages/examples/flask/flask-cli-appgroup.markdown

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ sidebartitle: flask.cli AppGroup
77
meta: Example code for understanding how to use the AppGroup class from the flask.cli module of the Flask project.
88

99

10-
AppGroup is a class within the flask.cli module of the Flask project.
10+
[AppGroup](https://github.com/pallets/flask/blob/master/src/flask/cli.py)
11+
is a class within the flask.cli module of the Flask project. It
12+
works like the
13+
[Click Group](https://click.palletsprojects.com/en/7.x/commands/)
14+
class and automatically wraps the functions using
15+
[with_appcontext](/flask-cli-with-appcontext-examples.html).
1116

1217

1318
## Example 1 from indico

content/pages/examples/flask/flask-cli-flaskgroup.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ meta: Example code for understanding how to use the FlaskGroup class from the fl
99

1010
[FlaskGroup](https://github.com/pallets/flask/blob/master/src/flask/cli.py)
1111
is a class within the flask.cli module of the Flask project. FlaskGroup
12-
is a subclass of AppGroup that provides for loading more commands from
13-
a configured Flask app. Generally, only advanced use cases will need to
14-
use this class.
12+
is a subclass of [AppGroup](/flask-cli-appgroup-examples.html) that provides
13+
for loading more commands from a configured Flask app. Generally, only
14+
advanced use cases will need to use this class.
1515

1616

1717
## Example 1 from FlaskBB

content/pages/examples/sqlalchemy/sqlalchemy-dialects-mssql.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: sqlalchemy-dialects-mssql-examples
44
sortorder: 500031000
55
toc: False
66
sidebartitle: sqlalchemy.dialects mssql
7-
meta: Python example code for the mssql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
7+
meta: Python example code that shows how to use the mssql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

1010
mssql is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.

content/pages/examples/sqlalchemy/sqlalchemy-dialects-mysql-pymysql.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: sqlalchemy-dialects-mysql-pymysql-examples
44
sortorder: 500031005
55
toc: False
66
sidebartitle: sqlalchemy.dialects.mysql pymysql
7-
meta: Python example code for the pymysql callable from the sqlalchemy.dialects.mysql module of the SQLAlchemy project.
7+
meta: Python example code that shows how to use the pymysql callable from the sqlalchemy.dialects.mysql module of the SQLAlchemy project.
88

99

1010
pymysql is a callable within the sqlalchemy.dialects.mysql module of the SQLAlchemy project.

content/pages/examples/sqlalchemy/sqlalchemy-dialects-mysql.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: sqlalchemy-dialects-mysql-examples
44
sortorder: 500031001
55
toc: False
66
sidebartitle: sqlalchemy.dialects mysql
7-
meta: Python example code for the mysql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
7+
meta: Python example code that shows how to use the mysql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

1010
mysql is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.

content/pages/examples/sqlalchemy/sqlalchemy-dialects-oracle.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: sqlalchemy-dialects-oracle-examples
44
sortorder: 500031002
55
toc: False
66
sidebartitle: sqlalchemy.dialects oracle
7-
meta: Python example code for the oracle callable from the sqlalchemy.dialects module of the SQLAlchemy project.
7+
meta: Python example code that shows how to use the oracle callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

1010
oracle is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.

content/pages/examples/sqlalchemy/sqlalchemy-dialects-postgresql-array.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: sqlalchemy-dialects-postgresql-array-examples
44
sortorder: 500031006
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql ARRAY
7-
meta: Python example code for the ARRAY constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
7+
meta: Python example code that shows how to use the ARRAY constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
88

99

1010
ARRAY is a constant within the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
title: sqlalchemy.dialects.postgresql.base PGCompiler Example Code
2+
category: page
3+
slug: sqlalchemy-dialects-postgresql-base-pgcompiler-examples
4+
sortorder: 500031015
5+
toc: False
6+
sidebartitle: sqlalchemy.dialects.postgresql.base PGCompiler
7+
meta: Example code for understanding how to use the PGCompiler class from the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
8+
9+
10+
PGCompiler is a class within the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
11+
12+
13+
## Example 1 from sqlalchemy-clickhouse
14+
[sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse)
15+
is a [SQLAlchemy Dialect](https://docs.sqlalchemy.org/en/13/dialects/)
16+
for communicating with the open source [ClickHouse](https://clickhouse.tech/)
17+
database management system. ClickHouse is column-oriented and therefore
18+
better for some use cases and worse for others compared to a traditional
19+
[relational database](/databases.html).
20+
21+
The code for this project is open sourced under the
22+
[MIT license](https://github.com/cloudflare/sqlalchemy-clickhouse/blob/master/LICENSE.txt)
23+
while ClickHouse is provided as open source under the
24+
[Apache License 2.0](https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE).
25+
26+
[**sqlalchemy-clickhouse / base.py**](https://github.com/cloudflare/sqlalchemy-clickhouse/blob/master/././base.py)
27+
28+
```python
29+
# base.py
30+
31+
import re
32+
33+
import sqlalchemy.types as sqltypes
34+
from sqlalchemy import exc as sa_exc
35+
from sqlalchemy import util as sa_util
36+
from sqlalchemy.engine import default, reflection
37+
from sqlalchemy.sql import compiler, expression
38+
from sqlalchemy.sql.elements import quoted_name
39+
~~from sqlalchemy.dialects.postgresql.base import PGCompiler, PGIdentifierPreparer
40+
from sqlalchemy.types import (
41+
CHAR, DATE, DATETIME, INTEGER, SMALLINT, BIGINT, DECIMAL, TIME,
42+
TIMESTAMP, VARCHAR, BINARY, BOOLEAN, FLOAT, REAL)
43+
44+
VERSION = (0, 1, 0, None)
45+
46+
colspecs = {}
47+
48+
class ARRAY(sqltypes.TypeEngine):
49+
__visit_name__ = 'ARRAY'
50+
51+
ischema_names = {
52+
'Int64': INTEGER,
53+
'Int32': INTEGER,
54+
'Int16': INTEGER,
55+
'Int8': INTEGER,
56+
'UInt64': INTEGER,
57+
'UInt32': INTEGER,
58+
'UInt16': INTEGER,
59+
'UInt8': INTEGER,
60+
'Date': DATE,
61+
'DateTime': DATETIME,
62+
'Float64': FLOAT,
63+
'Float32': FLOAT,
64+
'String': VARCHAR,
65+
'FixedString': VARCHAR,
66+
'Enum': VARCHAR,
67+
'Enum8': VARCHAR,
68+
'Enum16': VARCHAR,
69+
'Array': ARRAY,
70+
}
71+
72+
class ClickHouseIdentifierPreparer(PGIdentifierPreparer):
73+
def quote_identifier(self, value):
74+
return self._escape_identifier(value)
75+
def quote(self, ident, force=None):
76+
if self._requires_quotes(ident):
77+
return '"{}"'.format(ident)
78+
return ident
79+
80+
~~class ClickHouseCompiler(PGCompiler):
81+
def visit_count_func(self, fn, **kw):
82+
return 'count{0}'.format(self.process(fn.clause_expr, **kw))
83+
84+
def visit_random_func(self, fn, **kw):
85+
return 'rand()'
86+
87+
def visit_now_func(self, fn, **kw):
88+
return 'now()'
89+
90+
def visit_current_date_func(self, fn, **kw):
91+
return 'today()'
92+
93+
def visit_true(self, element, **kw):
94+
return '1'
95+
96+
def visit_false(self, element, **kw):
97+
return '0'
98+
99+
def visit_cast(self, cast, **kwargs):
100+
if self.dialect.supports_cast:
101+
return super(ClickHouseCompiler, self).visit_cast(cast, **kwargs)
102+
else:
103+
return self.process(cast.clause, **kwargs)
104+
105+
106+
107+
## ... source file continues with no further PGCompiler examples...
108+
109+
```
110+

0 commit comments

Comments
 (0)