snowlib 0.4.2__tar.gz → 0.4.4__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 (47) hide show
  1. {snowlib-0.4.2 → snowlib-0.4.4}/PKG-INFO +1 -1
  2. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/__init__.py +1 -1
  3. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/schema.py +52 -0
  4. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/stage.py +21 -2
  5. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/PKG-INFO +1 -1
  6. {snowlib-0.4.2 → snowlib-0.4.4}/LICENSE +0 -0
  7. {snowlib-0.4.2 → snowlib-0.4.4}/README.md +0 -0
  8. {snowlib-0.4.2 → snowlib-0.4.4}/licenses/THIRD_PARTY.md +0 -0
  9. {snowlib-0.4.2 → snowlib-0.4.4}/pyproject.toml +0 -0
  10. {snowlib-0.4.2 → snowlib-0.4.4}/setup.cfg +0 -0
  11. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/_data/connections.toml.example +0 -0
  12. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/_data/test_config.toml.example +0 -0
  13. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/__init__.py +0 -0
  14. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/base.py +0 -0
  15. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/connection.py +0 -0
  16. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/paths.py +0 -0
  17. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/profiles.py +0 -0
  18. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/context.py +0 -0
  19. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/__init__.py +0 -0
  20. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/__init__.py +0 -0
  21. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/core.py +0 -0
  22. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/fqn.py +0 -0
  23. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/schema_child.py +0 -0
  24. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/show.py +0 -0
  25. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/column.py +0 -0
  26. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/database.py +0 -0
  27. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/__init__.py +0 -0
  28. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/base.py +0 -0
  29. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/dynamic_table.py +0 -0
  30. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/materialized_view.py +0 -0
  31. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/table.py +0 -0
  32. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/view.py +0 -0
  33. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/__init__.py +0 -0
  34. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/async_query.py +0 -0
  35. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/execute.py +0 -0
  36. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/result.py +0 -0
  37. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/py.typed +0 -0
  38. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/session.py +0 -0
  39. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/sqlalchemy.py +0 -0
  40. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/identifiers.py +0 -0
  41. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/json_columns.py +0 -0
  42. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/query.py +0 -0
  43. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/schema.py +0 -0
  44. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/SOURCES.txt +0 -0
  45. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/dependency_links.txt +0 -0
  46. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/requires.txt +0 -0
  47. {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowlib
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Python-Snowflake utilities
5
5
  Author: Rashad Aziz
6
6
  Maintainer: Rashad Aziz
@@ -43,7 +43,7 @@ from snowlib.models import (
43
43
  # Session: Context-bound convenience layer
44
44
  from snowlib.session import Session, create_session
45
45
 
46
- __version__ = "0.4.2"
46
+ __version__ = "0.4.4"
47
47
  __all__ = [
48
48
  # Layer 1: Configuration & Connection
49
49
  "load_profile",
@@ -23,6 +23,58 @@ class Schema(Container):
23
23
  super().__init__(context)
24
24
  self._fqn = FQN.from_parts(database, name)
25
25
 
26
+ @classmethod
27
+ def from_name(
28
+ cls,
29
+ name: str,
30
+ context: SnowflakeContext,
31
+ default_database: str | None = None,
32
+ default_schema: str | None = None,
33
+ **kwargs: object
34
+ ) -> 'Schema':
35
+ """Parse qualified name and resolve missing parts from context.
36
+
37
+ Args:
38
+ name: Schema name in format 'DATABASE.SCHEMA' or 'SCHEMA'
39
+ context: SnowflakeContext to use for resolution
40
+ default_database: Ignored (Schema doesn't use default_database)
41
+ default_schema: Ignored (Schema doesn't use default_schema)
42
+ **kwargs: Additional arguments (ignored)
43
+
44
+ Returns:
45
+ Schema instance
46
+
47
+ Raises:
48
+ ValueError: If name cannot be resolved
49
+
50
+ Examples:
51
+ >>> Schema.from_name("MY_DB.MY_SCHEMA", ctx)
52
+ >>> Schema.from_name("MY_SCHEMA", ctx) # Uses current database
53
+ """
54
+ parts = name.split(".")
55
+
56
+ if len(parts) == 2:
57
+ # Fully qualified: DATABASE.SCHEMA
58
+ return cls(parts[0], parts[1], context)
59
+
60
+ elif len(parts) == 1:
61
+ # Need database from context: SCHEMA
62
+ db = context.current_database
63
+ if not db:
64
+ msg = (
65
+ f"Cannot resolve '{name}': no database in context. "
66
+ "Use DATABASE.SCHEMA format or USE DATABASE first."
67
+ )
68
+ raise ValueError(msg)
69
+ return cls(db, parts[0], context)
70
+
71
+ else:
72
+ msg = (
73
+ f"Invalid schema name '{name}'. "
74
+ "Expected format: 'DATABASE.SCHEMA' or 'SCHEMA'."
75
+ )
76
+ raise ValueError(msg)
77
+
26
78
  @property
27
79
  def database(self) -> 'Database':
28
80
  """Get parent database object"""
@@ -127,10 +127,29 @@ class Stage(SchemaChild):
127
127
  auto_compress: bool = True,
128
128
  overwrite: bool = False,
129
129
  show_progress: bool = True,
130
+ prefix: Optional[str] = None,
130
131
  ) -> list[dict[str, Any]]:
131
- """Upload local files to the stage with progress bar"""
132
+ """Upload local files to the stage with progress bar
133
+
134
+ Args:
135
+ files: List of local file paths to upload
136
+ auto_compress: Whether to automatically compress files during upload
137
+ overwrite: Whether to overwrite existing files in the stage
138
+ show_progress: Whether to show progress bar (requires tqdm)
139
+ prefix: Optional subdirectory path within the stage (e.g., 'courses', 'data/2024')
140
+
141
+ Returns:
142
+ List of dicts with upload results for each file
143
+ """
132
144
  results = []
133
145
 
146
+ # Build target path with optional prefix
147
+ target_path = self.stage_path
148
+ if prefix:
149
+ # Normalize prefix (strip leading/trailing slashes)
150
+ prefix = prefix.strip('/')
151
+ target_path = f"{self.stage_path}/{prefix}"
152
+
134
153
  iterator = tqdm(files, desc="Uploading") if (show_progress and HAS_TQDM and tqdm is not None) else files
135
154
 
136
155
  for file_path in iterator:
@@ -142,7 +161,7 @@ class Stage(SchemaChild):
142
161
  })
143
162
  continue
144
163
 
145
- sql = f"PUT 'file://{file_path.as_posix()}' {self.stage_path}"
164
+ sql = f"PUT 'file://{file_path.as_posix()}' {target_path}"
146
165
  sql += f" AUTO_COMPRESS = {str(auto_compress).upper()}"
147
166
  sql += f" OVERWRITE = {str(overwrite).upper()}"
148
167
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowlib
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Python-Snowflake utilities
5
5
  Author: Rashad Aziz
6
6
  Maintainer: Rashad Aziz
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes