Skip to content

Commit ba6206d

Browse files
committed
working on sqlalchemy examples
1 parent a45f4b7 commit ba6206d

File tree

143 files changed

+2281
-297
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

+2281
-297
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
title: sqlalchemy.databases mysql Example Code
2+
category: page
3+
slug: sqlalchemy-databases-mysql-examples
4+
sortorder: 500031000
5+
toc: False
6+
sidebartitle: sqlalchemy.databases mysql
7+
meta: Python example code that shows how to use the mysql callable from the sqlalchemy.databases module of the SQLAlchemy project.
8+
9+
10+
`mysql` is a callable within the `sqlalchemy.databases` module of the SQLAlchemy project.
11+
12+
13+
14+
## Example 1 from PyHive
15+
[PyHive](https://github.com/dropbox/PyHive)
16+
([PyPI package information](https://pypi.org/project/PyHive/))
17+
is a set of [DB-API](https://www.python.org/dev/peps/pep-0249/)
18+
and
19+
[SQLAlchemy](/sqlalchemy.html)
20+
interfaces that make it easier to use [Presto](https://prestodb.io/)
21+
and [Apache Hive](http://hive.apache.org/) with Python.
22+
[Dropbox's engineering team](https://www.dropbox.com/jobs/teams/engineering)
23+
created this code library, open sourced it and put it out under
24+
the [Apache 2.0 license](https://github.com/dropbox/PyHive/blob/master/LICENSE).
25+
26+
[**PyHive / pyhive / sqlalchemy_presto.py**](https://github.com/dropbox/PyHive/blob/master/pyhive/./sqlalchemy_presto.py)
27+
28+
```python
29+
# sqlalchemy_presto.py
30+
31+
from __future__ import absolute_import
32+
from __future__ import unicode_literals
33+
34+
import re
35+
from sqlalchemy import exc
36+
from sqlalchemy import types
37+
from sqlalchemy import util
38+
~~from sqlalchemy.databases import mysql
39+
from sqlalchemy.engine import default
40+
from sqlalchemy.sql import compiler
41+
from sqlalchemy.sql.compiler import SQLCompiler
42+
43+
from pyhive import presto
44+
from pyhive.common import UniversalSet
45+
46+
47+
class PrestoIdentifierPreparer(compiler.IdentifierPreparer):
48+
reserved_words = UniversalSet()
49+
50+
51+
_type_map = {
52+
'boolean': types.Boolean,
53+
~~ 'tinyint': mysql.MSTinyInteger,
54+
'smallint': types.SmallInteger,
55+
'integer': types.Integer,
56+
'bigint': types.BigInteger,
57+
'real': types.Float,
58+
'double': types.Float,
59+
'varchar': types.String,
60+
'timestamp': types.TIMESTAMP,
61+
'date': types.DATE,
62+
'varbinary': types.VARBINARY,
63+
}
64+
65+
66+
class PrestoCompiler(SQLCompiler):
67+
def visit_char_length_func(self, fn, **kw):
68+
return 'length{}'.format(self.function_argspec(fn, **kw))
69+
70+
71+
class PrestoTypeCompiler(compiler.GenericTypeCompiler):
72+
def visit_CLOB(self, type_, **kw):
73+
raise ValueError("Presto does not support the CLOB column type.")
74+
75+
def visit_NCLOB(self, type_, **kw):
76+
raise ValueError("Presto does not support the NCLOB column type.")
77+
78+
79+
80+
## ... source file continues with no further mysql examples...
81+
82+
```
83+

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
title: sqlalchemy.dialects mssql Example Code
22
category: page
33
slug: sqlalchemy-dialects-mssql-examples
4-
sortorder: 500031000
4+
sortorder: 500031001
55
toc: False
66
sidebartitle: sqlalchemy.dialects mssql
77
meta: Python example code that shows how to use the mssql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

10-
mssql is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.
10+
`mssql` is a callable within the `sqlalchemy.dialects` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-mysql-examples.html">mysql</a>,
13+
<a href="/sqlalchemy-dialects-oracle-examples.html">oracle</a>,
14+
<a href="/sqlalchemy-dialects-postgresql-examples.html">postgresql</a>,
15+
and <a href="/sqlalchemy-dialects-sqlite-examples.html">sqlite</a>
16+
are several other callables with code examples from the same `sqlalchemy.dialects` package.
1217

1318
## Example 1 from marshmallow-sqlalchemy
1419
[marshmallow-sqlalchemy](https://github.com/marshmallow-code/marshmallow-sqlalchemy)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
title: sqlalchemy.dialects.mysql pymysql Example Code
22
category: page
33
slug: sqlalchemy-dialects-mysql-pymysql-examples
4-
sortorder: 500031005
4+
sortorder: 500031006
55
toc: False
66
sidebartitle: sqlalchemy.dialects.mysql pymysql
77
meta: Python example code that shows how to use the pymysql callable from the sqlalchemy.dialects.mysql module of the SQLAlchemy project.
88

99

10-
pymysql is a callable within the sqlalchemy.dialects.mysql module of the SQLAlchemy project.
10+
`pymysql` is a callable within the `sqlalchemy.dialects.mysql` module of the SQLAlchemy project.
11+
1112

1213

1314
## Example 1 from databases

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
title: sqlalchemy.dialects mysql Example Code
22
category: page
33
slug: sqlalchemy-dialects-mysql-examples
4-
sortorder: 500031001
4+
sortorder: 500031002
55
toc: False
66
sidebartitle: sqlalchemy.dialects mysql
77
meta: Python example code that shows how to use the mysql callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

10-
mysql is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.
10+
`mysql` is a callable within the `sqlalchemy.dialects` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-mssql-examples.html">mssql</a>,
13+
<a href="/sqlalchemy-dialects-oracle-examples.html">oracle</a>,
14+
<a href="/sqlalchemy-dialects-postgresql-examples.html">postgresql</a>,
15+
and <a href="/sqlalchemy-dialects-sqlite-examples.html">sqlite</a>
16+
are several other callables with code examples from the same `sqlalchemy.dialects` package.
1217

1318
## Example 1 from marshmallow-sqlalchemy
1419
[marshmallow-sqlalchemy](https://github.com/marshmallow-code/marshmallow-sqlalchemy)

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
title: sqlalchemy.dialects oracle Example Code
22
category: page
33
slug: sqlalchemy-dialects-oracle-examples
4-
sortorder: 500031002
4+
sortorder: 500031003
55
toc: False
66
sidebartitle: sqlalchemy.dialects oracle
77
meta: Python example code that shows how to use the oracle callable from the sqlalchemy.dialects module of the SQLAlchemy project.
88

99

10-
oracle is a callable within the sqlalchemy.dialects module of the SQLAlchemy project.
10+
`oracle` is a callable within the `sqlalchemy.dialects` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-mssql-examples.html">mssql</a>,
13+
<a href="/sqlalchemy-dialects-mysql-examples.html">mysql</a>,
14+
<a href="/sqlalchemy-dialects-postgresql-examples.html">postgresql</a>,
15+
and <a href="/sqlalchemy-dialects-sqlite-examples.html">sqlite</a>
16+
are several other callables with code examples from the same `sqlalchemy.dialects` package.
1217

1318
## Example 1 from sqlalchemy-utils
1419
[sqlalchemy-utils](https://github.com/kvesteri/sqlalchemy-utils)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
title: sqlalchemy.dialects.postgresql ARRAY Example Code
22
category: page
33
slug: sqlalchemy-dialects-postgresql-array-examples
4-
sortorder: 500031006
4+
sortorder: 500031007
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql ARRAY
77
meta: Python example code that shows how to use the ARRAY constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
88

99

10-
ARRAY is a constant within the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
10+
`ARRAY` is a constant within the `sqlalchemy.dialects.postgresql` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-postgresql-bigint-examples.html">BIGINT</a>,
13+
<a href="/sqlalchemy-dialects-postgresql-bit-examples.html">BIT</a>,
14+
<a href="/sqlalchemy-dialects-postgresql-double-precision-examples.html">DOUBLE_PRECISION</a>,
15+
<a href="/sqlalchemy-dialects-postgresql-excludeconstraint-examples.html">ExcludeConstraint</a>,
16+
<a href="/sqlalchemy-dialects-postgresql-integer-examples.html">INTEGER</a>,
17+
<a href="/sqlalchemy-dialects-postgresql-json-examples.html">JSON</a>,
18+
<a href="/sqlalchemy-dialects-postgresql-tsvector-examples.html">TSVECTOR</a>,
19+
<a href="/sqlalchemy-dialects-postgresql-array-examples.html">array</a>,
20+
<a href="/sqlalchemy-dialects-postgresql-json-examples.html">json</a>,
21+
and <a href="/sqlalchemy-dialects-postgresql-pypostgresql-examples.html">pypostgresql</a>
22+
are several other callables with code examples from the same `sqlalchemy.dialects.postgresql` package.
1223

1324
## Example 1 from sqlacodegen
1425
[sqlacodegen](https://github.com/agronholm/sqlacodegen)

content/pages/examples/sqlalchemy/sqlalchemy-dialects-postgresql-base-pgcompiler.markdown

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
title: sqlalchemy.dialects.postgresql.base PGCompiler Example Code
22
category: page
33
slug: sqlalchemy-dialects-postgresql-base-pgcompiler-examples
4-
sortorder: 500031015
4+
sortorder: 500031016
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql.base PGCompiler
77
meta: Example code for understanding how to use the PGCompiler class from the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
88

99

10-
PGCompiler is a class within the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
10+
`PGCompiler` is a class within the `sqlalchemy.dialects.postgresql.base` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-postgresql-base-pgidentifierpreparer-examples.html">PGIdentifierPreparer</a>
13+
and
14+
<a href="/sqlalchemy-dialects-postgresql-base-pgtypecompiler-examples.html">PGTypeCompiler</a>
15+
are a couple of other callables within the `sqlalchemy.dialects.postgresql.base` package that also have code examples.
1216

1317
## Example 1 from sqlalchemy-clickhouse
1418
[sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse)

content/pages/examples/sqlalchemy/sqlalchemy-dialects-postgresql-base-pgidentifierpreparer.markdown

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
title: sqlalchemy.dialects.postgresql.base PGIdentifierPreparer Example Code
22
category: page
33
slug: sqlalchemy-dialects-postgresql-base-pgidentifierpreparer-examples
4-
sortorder: 500031016
4+
sortorder: 500031017
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql.base PGIdentifierPreparer
77
meta: Example code for understanding how to use the PGIdentifierPreparer class from the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
88

99

10-
PGIdentifierPreparer is a class within the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
10+
`PGIdentifierPreparer` is a class within the `sqlalchemy.dialects.postgresql.base` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-postgresql-base-pgcompiler-examples.html">PGCompiler</a>
13+
and
14+
<a href="/sqlalchemy-dialects-postgresql-base-pgtypecompiler-examples.html">PGTypeCompiler</a>
15+
are a couple of other callables within the `sqlalchemy.dialects.postgresql.base` package that also have code examples.
1216

1317
## Example 1 from sqlalchemy-clickhouse
1418
[sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse)

content/pages/examples/sqlalchemy/sqlalchemy-dialects-postgresql-base-pgtypecompiler.markdown

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
title: sqlalchemy.dialects.postgresql.base PGTypeCompiler Example Code
22
category: page
33
slug: sqlalchemy-dialects-postgresql-base-pgtypecompiler-examples
4-
sortorder: 500031017
4+
sortorder: 500031018
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql.base PGTypeCompiler
77
meta: Example code for understanding how to use the PGTypeCompiler class from the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
88

99

10-
PGTypeCompiler is a class within the sqlalchemy.dialects.postgresql.base module of the SQLAlchemy project.
10+
`PGTypeCompiler` is a class within the `sqlalchemy.dialects.postgresql.base` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-postgresql-base-pgcompiler-examples.html">PGCompiler</a>
13+
and
14+
<a href="/sqlalchemy-dialects-postgresql-base-pgidentifierpreparer-examples.html">PGIdentifierPreparer</a>
15+
are a couple of other callables within the `sqlalchemy.dialects.postgresql.base` package that also have code examples.
1216

1317
## Example 1 from sqlalchemy-utils
1418
[sqlalchemy-utils](https://github.com/kvesteri/sqlalchemy-utils)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
title: sqlalchemy.dialects.postgresql BIGINT Example Code
22
category: page
33
slug: sqlalchemy-dialects-postgresql-bigint-examples
4-
sortorder: 500031007
4+
sortorder: 500031008
55
toc: False
66
sidebartitle: sqlalchemy.dialects.postgresql BIGINT
77
meta: Python example code that shows how to use the BIGINT constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
88

99

10-
BIGINT is a constant within the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.
10+
`BIGINT` is a constant within the `sqlalchemy.dialects.postgresql` module of the SQLAlchemy project.
1111

12+
<a href="/sqlalchemy-dialects-postgresql-array-examples.html">ARRAY</a>,
13+
<a href="/sqlalchemy-dialects-postgresql-bit-examples.html">BIT</a>,
14+
<a href="/sqlalchemy-dialects-postgresql-double-precision-examples.html">DOUBLE_PRECISION</a>,
15+
<a href="/sqlalchemy-dialects-postgresql-excludeconstraint-examples.html">ExcludeConstraint</a>,
16+
<a href="/sqlalchemy-dialects-postgresql-integer-examples.html">INTEGER</a>,
17+
<a href="/sqlalchemy-dialects-postgresql-json-examples.html">JSON</a>,
18+
<a href="/sqlalchemy-dialects-postgresql-tsvector-examples.html">TSVECTOR</a>,
19+
<a href="/sqlalchemy-dialects-postgresql-array-examples.html">array</a>,
20+
<a href="/sqlalchemy-dialects-postgresql-json-examples.html">json</a>,
21+
and <a href="/sqlalchemy-dialects-postgresql-pypostgresql-examples.html">pypostgresql</a>
22+
are several other callables with code examples from the same `sqlalchemy.dialects.postgresql` package.
1223

1324
## Example 1 from alembic
1425
[Alembic](https://github.com/sqlalchemy/alembic)

0 commit comments

Comments
 (0)