sqlalchemy-risingwave 0.0.9__tar.gz → 1.0.0__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 (19) hide show
  1. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/PKG-INFO +17 -5
  2. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/README.md +12 -2
  3. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/setup.py +4 -3
  4. sqlalchemy-risingwave-1.0.0/sqlalchemy_risingwave/__init__.py +16 -0
  5. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave/base.py +33 -22
  6. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/PKG-INFO +17 -5
  7. sqlalchemy-risingwave-1.0.0/sqlalchemy_risingwave.egg-info/requires.txt +1 -0
  8. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/test/test_schema.py +16 -18
  9. sqlalchemy-risingwave-0.0.9/sqlalchemy_risingwave/__init__.py +0 -14
  10. sqlalchemy-risingwave-0.0.9/sqlalchemy_risingwave.egg-info/requires.txt +0 -1
  11. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/LICENSE +0 -0
  12. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/setup.cfg +0 -0
  13. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave/psycopg2.py +0 -0
  14. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave/requirements.py +0 -0
  15. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/SOURCES.txt +0 -0
  16. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/dependency_links.txt +0 -0
  17. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/entry_points.txt +0 -0
  18. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/not-zip-safe +0 -0
  19. {sqlalchemy-risingwave-0.0.9 → sqlalchemy-risingwave-1.0.0}/sqlalchemy_risingwave.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-risingwave
3
- Version: 0.0.9
3
+ Version: 1.0.0
4
4
  Summary: RisingWave dialect for SQLAlchemy
5
5
  Home-page: https://github.com/risingwavelabs/risingwave
6
6
  Author: RisingWave Labs
@@ -12,15 +12,21 @@ Keywords: SQLAlchemy RisingWave
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: 3.7
17
15
  Classifier: Programming Language :: Python :: 3.8
18
16
  Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
22
+ Requires-Dist: SQLAlchemy<2,>=1.4
21
23
 
22
24
  # RisingWave dialect for SQLAlchemy
23
25
 
26
+ SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. https://www.sqlalchemy.org/
27
+
28
+ RisingWave is a cloud-native streaming database that uses SQL as the interface language. It is designed to reduce the complexity and cost of building real-time applications. https://www.risingwave.com
29
+
24
30
  ## Prerequisites
25
31
 
26
32
  For psycopg2 support you must install either:
@@ -65,7 +71,13 @@ pytest # to run the test
65
71
  ```
66
72
 
67
73
  ## Ref
68
- [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
69
74
 
70
- [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
75
+ - [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
76
+
77
+ - [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
78
+
79
+ - [RisingWave: Open-Source Streaming Database](https://www.risingwave.com/database/)
80
+
81
+ - [RisingWave Cloud](https://www.risingwave.com/cloud/)
71
82
 
83
+ - [What is RisingWave?](https://docs.risingwave.com/docs/current/intro/)
@@ -1,5 +1,9 @@
1
1
  # RisingWave dialect for SQLAlchemy
2
2
 
3
+ SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. https://www.sqlalchemy.org/
4
+
5
+ RisingWave is a cloud-native streaming database that uses SQL as the interface language. It is designed to reduce the complexity and cost of building real-time applications. https://www.risingwave.com
6
+
3
7
  ## Prerequisites
4
8
 
5
9
  For psycopg2 support you must install either:
@@ -44,7 +48,13 @@ pytest # to run the test
44
48
  ```
45
49
 
46
50
  ## Ref
47
- [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
48
51
 
49
- [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
52
+ - [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
53
+
54
+ - [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
55
+
56
+ - [RisingWave: Open-Source Streaming Database](https://www.risingwave.com/database/)
57
+
58
+ - [RisingWave Cloud](https://www.risingwave.com/cloud/)
50
59
 
60
+ - [What is RisingWave?](https://docs.risingwave.com/docs/current/intro/)
@@ -23,10 +23,11 @@ setup(
23
23
  "License :: OSI Approved :: Apache Software License",
24
24
  "Programming Language :: Python :: 3",
25
25
  "Programming Language :: Python :: 3 :: Only",
26
- "Programming Language :: Python :: 3.6",
27
- "Programming Language :: Python :: 3.7",
28
26
  "Programming Language :: Python :: 3.8",
29
27
  "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
30
31
  ],
31
32
  keywords="SQLAlchemy RisingWave",
32
33
  project_urls={
@@ -35,7 +36,7 @@ setup(
35
36
  },
36
37
  packages=find_packages(include=["sqlalchemy_risingwave"]),
37
38
  include_package_data=True,
38
- install_requires=["SQLAlchemy"],
39
+ install_requires=["SQLAlchemy>=1.4,<2"],
39
40
  zip_safe=False,
40
41
  # # Do not support dialects now.
41
42
  entry_points={
@@ -0,0 +1,16 @@
1
+ from sqlalchemy.dialects import registry as _registry
2
+
3
+ __version__ = "1.0.0"
4
+
5
+ _registry.register(
6
+ "risingwave.psycopg2",
7
+ "sqlalchemy_risingwave.psycopg2",
8
+ "RisingWaveDialect_psycopg2",
9
+ )
10
+
11
+ # asyncpg is not supported yet
12
+ # _registry.register(
13
+ # "risingwave.asyncpg",
14
+ # "sqlalchemy_risingwave.asyncpg",
15
+ # "RisingWaveDialect_asyncpg",
16
+ # )
@@ -4,27 +4,42 @@ from sqlalchemy.dialects.postgresql.base import PGDialect
4
4
  from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2
5
5
  from sqlalchemy import text
6
6
  from sqlalchemy.util import warn
7
- from sqlalchemy.dialects.postgresql import INET
8
- from sqlalchemy.dialects.postgresql import UUID
9
7
 
10
8
  import sqlalchemy.types as sqltypes
9
+
11
10
  _type_map = {
11
+ "bool": sqltypes.BOOLEAN, # DataType::Boolean
12
12
  "boolean": sqltypes.BOOLEAN, # DataType::Boolean
13
13
  "smallint": sqltypes.SMALLINT, # DataType::Int16
14
+ "int2": sqltypes.SMALLINT, # DataType::Int16
14
15
  "integer": sqltypes.INT, # DataType::Int32
16
+ "int4": sqltypes.INT, # DataType::Int32
15
17
  "bigint": sqltypes.BIGINT, # DataType::Int64
18
+ "int8": sqltypes.BIGINT, # DataType::Int64
16
19
  "real": sqltypes.FLOAT, # DataType::Float32
20
+ "float4": sqltypes.FLOAT, # DataType::Float32
17
21
  "double precision": sqltypes.FLOAT, # DataType::Float64
22
+ "float8": sqltypes.FLOAT, # DataType::Float64
18
23
  "numeric": sqltypes.DECIMAL, # DataType::Decimal
24
+ "decimal": sqltypes.DECIMAL, # DataType::Decimal
19
25
  "date": sqltypes.DATE, # DataType::Date
20
26
  "varchar": sqltypes.VARCHAR, # DataType::Varchar
27
+ "character varying": sqltypes.VARCHAR, # DataType::Varchar
28
+ "time": sqltypes.Time, # DataType::Time
21
29
  "time without time zone": sqltypes.Time, # DataType::Time
30
+ "timestamp": sqltypes.TIMESTAMP, # DataType::Timestamp
22
31
  "timestamp without time zone": sqltypes.TIMESTAMP, # DataType::Timestamp
32
+ "timestamptz": sqltypes.TIMESTAMP, # DataType::Timestampz
23
33
  "timestamp with time zone": sqltypes.TIMESTAMP, # DataType::Timestampz
24
34
  "interval": sqltypes.Interval, # DataType::Interval
35
+ "bytea": sqltypes.BLOB,
36
+ "jsonb": sqltypes.JSON,
25
37
  }
26
38
 
27
39
 
40
+ # Unsupported: Int256, Serial, Struct, List
41
+
42
+
28
43
  class RisingWaveDialect(PGDialect_psycopg2):
29
44
  name = "risingwave"
30
45
 
@@ -45,28 +60,24 @@ class RisingWaveDialect(PGDialect_psycopg2):
45
60
  return (9, 5, 0)
46
61
 
47
62
  def get_table_names(self, conn, schema=None, **kw):
48
- sql = (
49
- "SELECT table_name FROM information_schema.tables WHERE "
50
- "table_schema = :table_schema"
51
- )
52
- rows = conn.execute(
53
- text(sql),
54
- {"table_schema": schema or self.default_schema_name},
55
- )
56
- return [row.table_name for row in rows]
63
+ sql = "SELECT tablename FROM pg_tables"
64
+ if schema is not None:
65
+ sql += f" WHERE schemaname = '{schema or self.default_schema_name}'"
66
+ else:
67
+ sql += " WHERE schemaname <> 'rw_catalog' and schemaname <> 'pg_catalog' and schemaname <> 'information_schema'"
68
+ rows = conn.execute(text(sql))
69
+ return [row.tablename for row in rows]
57
70
 
58
71
  def get_view_names(self, conn, schema=None, **kw):
59
- sql = (
60
- "select * from pg_catalog.pg_views"
61
- )
62
- rows = conn.execute(
63
- text(sql),
64
- {"table_schema": schema or self.default_schema_name},
65
- )
66
-
72
+ sql = "SELECT viewname FROM pg_views"
73
+ if schema is not None:
74
+ sql += f" WHERE schemaname = '{schema or self.default_schema_name}'"
75
+ else:
76
+ sql += " WHERE schemaname <> 'rw_catalog' and schemaname <> 'pg_catalog' and schemaname <> 'information_schema'"
77
+ rows = conn.execute(text(sql))
67
78
  return [row.viewname for row in rows]
68
79
 
69
- def has_table(self, conn, table, schema=None):
80
+ def has_table(self, conn, table, schema=None, **kw):
70
81
  return any(t == table for t in self.get_table_names(conn, schema=schema))
71
82
 
72
83
  def get_columns(self, conn, table_name, schema=None, **kw):
@@ -142,7 +153,7 @@ class RisingWaveDialect(PGDialect_psycopg2):
142
153
 
143
154
  indexes = {}
144
155
  for row in rows:
145
- if not row.relname in indexes:
156
+ if row.relname not in indexes:
146
157
  indexes[row.relname] = []
147
158
  indexes[row.relname].append(row.attname)
148
159
 
@@ -161,7 +172,7 @@ class RisingWaveDialect(PGDialect_psycopg2):
161
172
  raise []
162
173
 
163
174
  def get_foreign_keys(
164
- self, connection, table_name, schema=None, postgresql_ignore_search_path=False, **kw
175
+ self, connection, table_name, schema=None, postgresql_ignore_search_path=False, **kw
165
176
  ):
166
177
  return []
167
178
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-risingwave
3
- Version: 0.0.9
3
+ Version: 1.0.0
4
4
  Summary: RisingWave dialect for SQLAlchemy
5
5
  Home-page: https://github.com/risingwavelabs/risingwave
6
6
  Author: RisingWave Labs
@@ -12,15 +12,21 @@ Keywords: SQLAlchemy RisingWave
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: 3.7
17
15
  Classifier: Programming Language :: Python :: 3.8
18
16
  Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
22
+ Requires-Dist: SQLAlchemy<2,>=1.4
21
23
 
22
24
  # RisingWave dialect for SQLAlchemy
23
25
 
26
+ SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. https://www.sqlalchemy.org/
27
+
28
+ RisingWave is a cloud-native streaming database that uses SQL as the interface language. It is designed to reduce the complexity and cost of building real-time applications. https://www.risingwave.com
29
+
24
30
  ## Prerequisites
25
31
 
26
32
  For psycopg2 support you must install either:
@@ -65,7 +71,13 @@ pytest # to run the test
65
71
  ```
66
72
 
67
73
  ## Ref
68
- [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
69
74
 
70
- [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
75
+ - [Sqlalchemy dialects doc](https://github.com/sqlalchemy/sqlalchemy/blob/main/README.dialects.rst)
76
+
77
+ - [CocoroachDB sqlalchemy](https://github.com/cockroachdb/sqlalchemy-cockroachdb)
78
+
79
+ - [RisingWave: Open-Source Streaming Database](https://www.risingwave.com/database/)
80
+
81
+ - [RisingWave Cloud](https://www.risingwave.com/cloud/)
71
82
 
83
+ - [What is RisingWave?](https://docs.risingwave.com/docs/current/intro/)
@@ -7,11 +7,11 @@ class SchemaTest(fixtures.TestBase):
7
7
 
8
8
  def teardown_method(self, method):
9
9
  with testing.db.begin() as conn:
10
- conn.execute("DROP TABLE IF EXISTS users")
10
+ conn.execute(text("DROP TABLE IF EXISTS users"))
11
11
 
12
12
  def setup_method(self):
13
13
  with testing.db.begin() as conn:
14
- conn.execute("CREATE TABLE users (name STRING PRIMARY KEY)")
14
+ conn.execute(text("CREATE TABLE users (name STRING PRIMARY KEY)"))
15
15
  self.meta = MetaData(schema="public")
16
16
 
17
17
  def test_get_columns_indexes_across_schema(self):
@@ -19,38 +19,36 @@ class SchemaTest(fixtures.TestBase):
19
19
  # across schema table must use schema.table
20
20
  Table("users", self.meta, autoload_with=testing.db, schema="public")
21
21
 
22
- def test_returning_clause(self):
22
+ def test_has_table(self):
23
23
  with testing.db.begin() as conn:
24
24
  insp = inspect(testing.db)
25
- table_names = insp.get_table_names()
26
-
27
- for t in table_names:
28
- assert t == str("users")
25
+ assert insp.has_table(table_name="users", schema="public")
29
26
 
30
27
  def test_get_indexes(self):
31
28
  with testing.db.begin() as conn:
32
- conn.execute("CREATE TABLE three_columns (id1 INT, id2 INT, id3 INT)")
33
- conn.execute("CREATE INDEX three_columns_idx ON three_columns(id2) INCLUDE(id1)")
29
+ conn.execute(text("CREATE TABLE three_columns (id1 INT, id2 INT, id3 INT)"))
30
+ conn.execute(text("CREATE INDEX three_columns_idx ON three_columns(id2) INCLUDE(id1)"))
34
31
 
35
32
  insp = inspect(testing.db)
36
33
  indexes = insp.get_indexes("three_columns")
37
34
 
38
35
  assert len(indexes) == 1
39
36
  assert indexes[0]["name"] == "three_columns_idx"
40
- assert indexes[0]["column_names"] == ["id2", "id1"]
37
+ # pg will return `"id2", "id1"`
38
+ assert indexes[0]["column_names"] == ["id2"]
41
39
 
42
- conn.execute("DROP TABLE three_columns")
40
+ conn.execute(text("DROP TABLE three_columns"))
43
41
 
44
42
  def test_get_view_names(self):
45
43
  with testing.db.begin() as conn:
46
- conn.execute("CREATE TABLE three_columns (id1 INT, id2 INT, id3 INT)")
47
- conn.execute("CREATE VIEW three_view AS SELECT * from three_columns")
44
+ conn.execute(text("CREATE TABLE three_columns (id1 INT, id2 INT, id3 INT)"))
45
+ conn.execute(text("CREATE VIEW three_view AS SELECT * from three_columns"))
48
46
 
49
47
  insp = inspect(testing.db)
50
- indexes = insp.get_view_names()
48
+ views = insp.get_view_names()
51
49
 
52
- assert len(indexes) == 1
53
- assert indexes[0] == "three_view"
50
+ assert len(views) == 1
51
+ assert views[0] == "three_view"
54
52
 
55
- conn.execute("DROP VIEW three_view")
56
- conn.execute("DROP TABLE three_columns")
53
+ conn.execute(text("DROP VIEW three_view"))
54
+ conn.execute(text("DROP TABLE three_columns"))
@@ -1,14 +0,0 @@
1
- from sqlalchemy.dialects import registry as _registry
2
-
3
- __version__ = "0.0.9"
4
-
5
- _registry.register(
6
- "risingwave.psycopg2",
7
- "sqlalchemy_risingwave.psycopg2",
8
- "RisingWaveDialect_psycopg2",
9
- )
10
- _registry.register(
11
- "risingwave.asyncpg",
12
- "sqlalchemy_risingwave.asyncpg",
13
- "RisingWaveDialect_asyncpg",
14
- )