sqlalchemy-bigquery 0.0.4__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. sqlalchemy_bigquery-0.0.6/CHANGES.txt +7 -0
  2. sqlalchemy_bigquery-0.0.6/MANIFEST.in +13 -0
  3. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/PKG-INFO +5 -3
  4. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/README.rst +4 -2
  5. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery/__init__.py +1 -1
  6. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery/base.py +22 -2
  7. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/PKG-INFO +5 -3
  8. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/SOURCES.txt +3 -0
  9. sqlalchemy_bigquery-0.0.6/test/__init__.py +0 -0
  10. sqlalchemy_bigquery-0.0.6/test/conftest.py +14 -0
  11. sqlalchemy_bigquery-0.0.6/test/test_suite.py +101 -0
  12. sqlalchemy_bigquery-0.0.4/MANIFEST.in +0 -1
  13. sqlalchemy_bigquery-0.0.4/test/test_suite.py +0 -50
  14. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/setup.cfg +1 -1
  15. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/setup.py +0 -0
  16. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery/pyodbc.py +0 -0
  17. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery/requirements.py +0 -0
  18. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
  19. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
  20. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/not-zip-safe +0 -0
  21. {sqlalchemy_bigquery-0.0.4 → sqlalchemy_bigquery-0.0.6}/sqlalchemy_bigquery.egg-info/top_level.txt +0 -0
@@ -0,0 +1,7 @@
1
+ **0.0.6 (2015-09-02) **
2
+
3
+ * Correct how the LIMIT clause compiles (louispotok)
4
+
5
+ **0.0.5**
6
+
7
+ * Basic implementation of a SQLAlchemy dialect for Google BigQuery.
@@ -0,0 +1,13 @@
1
+ # any kind of "*" pulls in __init__.pyc files,
2
+ # so all extensions are explicit.
3
+
4
+ recursive-include doc *.html *.css *.txt *.js *.jpg *.png *.py Makefile *.rst *.mako *.sty
5
+ recursive-include examples *.py *.xml
6
+ recursive-include test *.py *.dat
7
+
8
+ # include the c extensions, which otherwise
9
+ # don't come in if --with-cextensions isn't specified.
10
+ recursive-include lib *.c *.txt
11
+
12
+ include README* AUTHORS LICENSE distribute_setup.py sa2to3.py ez_setup.py sqla_nose.py CHANGES*
13
+ prune doc/build/output
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: sqlalchemy_bigquery
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: BigQuery for SQLAlchemy
5
5
  Home-page: UNKNOWN
6
6
  Author: Conrad Dean
7
7
  Author-email: conrad.p.dean@gmail.com
8
8
  License: MIT
9
- Description: BigQuery dialect for SQLAlchemy.
9
+ Description: BigQuery dialect for SQLAlchemy
10
+ -------------------------------
10
11
 
11
12
  BigQuery implements a DSL that is similar to SQL with a few quirks:
12
13
 
@@ -19,7 +20,8 @@ Description: BigQuery dialect for SQLAlchemy.
19
20
  The first two issues (the non-standard "each" modifier for grouping and joining) has not been addressed yet. BigQuery pushes the responsibility of when to recognize a table is too big for certain operations, and shifts burden onto you when you want to use those modifiers. Sometimes you need them, sometimes you don't. Leaving this as an exercise to the user to just string replace those out of what this dialect returns.
20
21
 
21
22
 
22
- ### Usage
23
+ Usage
24
+ =====
23
25
 
24
26
  There currently isn't support for using sqlalchemy to connect to
25
27
  BigQuery. Currently there's only support for generating SQL to send
@@ -1,4 +1,5 @@
1
- BigQuery dialect for SQLAlchemy.
1
+ BigQuery dialect for SQLAlchemy
2
+ -------------------------------
2
3
 
3
4
  BigQuery implements a DSL that is similar to SQL with a few quirks:
4
5
 
@@ -11,7 +12,8 @@ BigQuery implements a DSL that is similar to SQL with a few quirks:
11
12
  The first two issues (the non-standard "each" modifier for grouping and joining) has not been addressed yet. BigQuery pushes the responsibility of when to recognize a table is too big for certain operations, and shifts burden onto you when you want to use those modifiers. Sometimes you need them, sometimes you don't. Leaving this as an exercise to the user to just string replace those out of what this dialect returns.
12
13
 
13
14
 
14
- ### Usage
15
+ Usage
16
+ =====
15
17
 
16
18
  There currently isn't support for using sqlalchemy to connect to
17
19
  BigQuery. Currently there's only support for generating SQL to send
@@ -1,4 +1,4 @@
1
- __version__ = '0.0.4'
1
+ __version__ = '0.0.6'
2
2
 
3
3
  from sqlalchemy.dialects import registry
4
4
 
@@ -7,7 +7,6 @@ Directly derived from the mssql dialect with minor modifications
7
7
  """
8
8
  import sqlalchemy.dialects.mssql.base as mssql_base
9
9
 
10
-
11
10
  from sqlalchemy.dialects.mssql.base import MSDialect
12
11
  from sqlalchemy.sql import compiler
13
12
  from sqlalchemy.sql import sqltypes
@@ -32,13 +31,34 @@ class BQString(sqltypes.String):
32
31
 
33
32
  def literal_processor(self, dialect):
34
33
  def process(value):
35
- value = value.replace("'", "\'")
34
+ value = value.replace("'", "\\'")
36
35
  return "'%s'" % value
37
36
  return process
38
37
 
39
38
 
40
39
  class BQSQLCompiler(mssql_base.MSSQLCompiler):
41
40
 
41
+ def get_select_precolumns(self,select, **kw):
42
+ """BQ uses TOP differently from MS-SQL"""
43
+ s = ""
44
+ if select._distinct:
45
+ s += "DISTINCT "
46
+
47
+ if s:
48
+ return s
49
+ else:
50
+ return compiler.SQLCompiler.get_select_precolumns(
51
+ self, select, **kw)
52
+
53
+ def limit_clause(self, select, **kw):
54
+ """Only supports simple (integer) LIMIT clause"""
55
+ s = ""
56
+ if select._simple_int_limit and not select._offset:
57
+ s += "\nLIMIT %d " % select._limit
58
+
59
+ return s
60
+
61
+
42
62
  def visit_column(self, column, add_to_result_map=None, **kwargs):
43
63
  # TODO: figure out how to do this immutably
44
64
  # force column rendering to not use quotes by declaring every col literal
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: sqlalchemy-bigquery
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: BigQuery for SQLAlchemy
5
5
  Home-page: UNKNOWN
6
6
  Author: Conrad Dean
7
7
  Author-email: conrad.p.dean@gmail.com
8
8
  License: MIT
9
- Description: BigQuery dialect for SQLAlchemy.
9
+ Description: BigQuery dialect for SQLAlchemy
10
+ -------------------------------
10
11
 
11
12
  BigQuery implements a DSL that is similar to SQL with a few quirks:
12
13
 
@@ -19,7 +20,8 @@ Description: BigQuery dialect for SQLAlchemy.
19
20
  The first two issues (the non-standard "each" modifier for grouping and joining) has not been addressed yet. BigQuery pushes the responsibility of when to recognize a table is too big for certain operations, and shifts burden onto you when you want to use those modifiers. Sometimes you need them, sometimes you don't. Leaving this as an exercise to the user to just string replace those out of what this dialect returns.
20
21
 
21
22
 
22
- ### Usage
23
+ Usage
24
+ =====
23
25
 
24
26
  There currently isn't support for using sqlalchemy to connect to
25
27
  BigQuery. Currently there's only support for generating SQL to send
@@ -1,3 +1,4 @@
1
+ CHANGES.txt
1
2
  MANIFEST.in
2
3
  README.rst
3
4
  setup.cfg
@@ -12,4 +13,6 @@ sqlalchemy_bigquery.egg-info/dependency_links.txt
12
13
  sqlalchemy_bigquery.egg-info/entry_points.txt
13
14
  sqlalchemy_bigquery.egg-info/not-zip-safe
14
15
  sqlalchemy_bigquery.egg-info/top_level.txt
16
+ test/__init__.py
17
+ test/conftest.py
15
18
  test/test_suite.py
File without changes
@@ -0,0 +1,14 @@
1
+ from sqlalchemy.dialects import registry
2
+
3
+ registry.register(
4
+ "bigquery",
5
+ "sqlalchemy_bigquery.pyodbc",
6
+ "BigQueryDialect_pyodbc"
7
+ )
8
+ registry.register(
9
+ "bigquery.pyodbc",
10
+ "sqlalchemy_bigquery.pyodbc",
11
+ "BigQueryDialect_pyodbc"
12
+ )
13
+
14
+ # from sqlalchemy.testing.plugin.pytestplugin import *
@@ -0,0 +1,101 @@
1
+ # from sqlalchemy.testing.suite import *
2
+
3
+ import sqlalchemy.sql as sql
4
+ from sqlalchemy import func
5
+
6
+ import sqlalchemy_bigquery
7
+ import sqlalchemy_bigquery.base as bq
8
+
9
+
10
+ def test_assert_correct_version():
11
+ """
12
+ yep. update it every time.
13
+
14
+ This is a dumb test, but I want it here to remind future committers that if
15
+ you make a change to the package, your change should probably include a
16
+ test which verifies why the change was made.
17
+
18
+ If you want your changes to be seen in PyPI, you have to rev the version.
19
+ If you rev the version without updating the test suite, you will break the
20
+ tests.
21
+ """
22
+
23
+ assert "0.0.6" == sqlalchemy_bigquery.__version__
24
+
25
+
26
+ def test_mixed_case_function_label_not_quoted():
27
+ s = sql.select([
28
+ func.sum().label("Pork")
29
+ ]).compile(
30
+ dialect=bq.BQDialect()
31
+ )
32
+ assert "[Pork]" not in str(s)
33
+ assert "Pork" in str(s)
34
+
35
+
36
+ def test_table_is_quoted_with_square_brackets():
37
+ s = sql.select([
38
+ func.sum().label("Pork")
39
+ ]).select_from(
40
+ sql.table("with.dot")
41
+ ).compile(
42
+ dialect=bq.BQDialect()
43
+ )
44
+ assert "[with.dot]" in str(s)
45
+
46
+
47
+ def test_mixed_case_column_not_quoted():
48
+ s = sql.select([
49
+ sql.column("Pork")
50
+ ]).compile(
51
+ dialect=bq.BQDialect()
52
+ )
53
+ assert "[Pork]" not in str(s)
54
+ assert "Pork" in str(s)
55
+
56
+
57
+ def test_string_literal_does_not_use_old_sql_quote_escaping():
58
+ s = sql.select([
59
+ func.look_at(sql.column("something") == "here's a single-quote")
60
+ ]).select_from(
61
+ sql.table("something_else")
62
+ ).compile(
63
+ compile_kwargs={"literal_binds": True},
64
+ dialect=bq.BQDialect()
65
+ )
66
+ assert "here''s" not in str(s)
67
+
68
+
69
+ def test_string_literals_correctly_quoted():
70
+ s = sql.select([
71
+ func.look_at(sql.column("something") == "here's a single-quote")
72
+ ]).select_from(
73
+ sql.table("something_else")
74
+ ).compile(
75
+ compile_kwargs={"literal_binds": True},
76
+ dialect=bq.BQDialect()
77
+ )
78
+ assert "here\\'s" in str(s)
79
+
80
+
81
+ def test_string_literals_not_oldstyle_quoted_in_func():
82
+ s = str(
83
+ sql.case(
84
+ [(sql.column("WHOA") == "Jason's", 1)],
85
+ else_=0
86
+ ).compile(
87
+ compile_kwargs={"literal_binds": True},
88
+ dialect=bq.BQDialect()
89
+ )
90
+ )
91
+ assert "Jason's" not in s
92
+
93
+
94
+ def test_limit_compiles_correctly():
95
+ s = sql.select([sql.column('col1'),sql.column('col2')
96
+ ]).select_from(
97
+ sql.table('table_name')
98
+ ).limit(5
99
+ ).compile(
100
+ dialect=bq.BQDialect())
101
+ assert ('LIMIT 5' in str(s)) and ('TOP 5' not in str(s))
@@ -1 +0,0 @@
1
- include README.rst
@@ -1,50 +0,0 @@
1
- # from sqlalchemy.testing.suite import *
2
-
3
- import sqlalchemy.sql as sql
4
- from sqlalchemy import func
5
-
6
- import sqlalchemy_bigquery.base as bq
7
-
8
-
9
- def test_mixed_case_function_label_not_quoted():
10
- s = sql.select([
11
- func.sum().label("Pork")
12
- ]).compile(
13
- dialect=bq.BQDialect()
14
- )
15
- assert "[Pork]" not in str(s)
16
- assert "Pork" in str(s)
17
-
18
-
19
- def test_table_is_quoted_with_square_brackets():
20
- s = sql.select([
21
- func.sum().label("Pork")
22
- ]).select_from(
23
- sql.table("with.dot")
24
- ).compile(
25
- dialect=bq.BQDialect()
26
- )
27
- assert "[with.dot]" in str(s)
28
-
29
-
30
- def test_mixed_case_column_not_quoted():
31
- s = sql.select([
32
- sql.column("Pork")
33
- ]).compile(
34
- dialect=bq.BQDialect()
35
- )
36
- assert "[Pork]" not in str(s)
37
- assert "Pork" in str(s)
38
-
39
-
40
- def test_string_literals_correctly_quoted():
41
- s = sql.select([
42
- func.look_at(sql.column("something"), "here's a single-quote")
43
- ]).select_from(
44
- sql.table("something_else")
45
- ).compile(
46
- compile_kwargs={"literal_binds": True},
47
- dialect=bq.BQDialect()
48
- )
49
- assert "here''s" not in str(s)
50
- assert "here\'s" in str(s)
@@ -1,6 +1,6 @@
1
1
  [egg_info]
2
- tag_build =
3
2
  tag_date = 0
3
+ tag_build =
4
4
  tag_svn_revision = 0
5
5
 
6
6
  [pytest]