fakesnow 0.9.10__tar.gz → 0.9.11__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 (32) hide show
  1. {fakesnow-0.9.10 → fakesnow-0.9.11}/PKG-INFO +2 -2
  2. {fakesnow-0.9.10 → fakesnow-0.9.11}/README.md +1 -1
  3. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/fakes.py +6 -1
  4. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/PKG-INFO +2 -2
  5. {fakesnow-0.9.10 → fakesnow-0.9.11}/pyproject.toml +1 -1
  6. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_fakes.py +20 -0
  7. {fakesnow-0.9.10 → fakesnow-0.9.11}/LICENSE +0 -0
  8. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/__init__.py +0 -0
  9. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/__main__.py +0 -0
  10. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/checks.py +0 -0
  11. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/cli.py +0 -0
  12. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/expr.py +0 -0
  13. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/fixtures.py +0 -0
  14. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/global_database.py +0 -0
  15. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/info_schema.py +0 -0
  16. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/macros.py +0 -0
  17. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/py.typed +0 -0
  18. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow/transforms.py +0 -0
  19. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/SOURCES.txt +0 -0
  20. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/dependency_links.txt +0 -0
  21. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/entry_points.txt +0 -0
  22. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/requires.txt +0 -0
  23. {fakesnow-0.9.10 → fakesnow-0.9.11}/fakesnow.egg-info/top_level.txt +0 -0
  24. {fakesnow-0.9.10 → fakesnow-0.9.11}/setup.cfg +0 -0
  25. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_checks.py +0 -0
  26. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_cli.py +0 -0
  27. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_expr.py +0 -0
  28. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_info_schema.py +0 -0
  29. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_patch.py +0 -0
  30. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_sqlalchemy.py +0 -0
  31. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_transforms.py +0 -0
  32. {fakesnow-0.9.10 → fakesnow-0.9.11}/tests/test_users.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakesnow
3
- Version: 0.9.10
3
+ Version: 0.9.11
4
4
  Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -357,7 +357,7 @@ For more detail see [tests/test_fakes.py](tests/test_fakes.py)
357
357
  ## Caveats
358
358
 
359
359
  - The order of rows is non deterministic and may not match Snowflake unless ORDER BY is fully specified.
360
- - A more liberal Snowflake SQL dialect than a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
360
+ - A more liberal Snowflake SQL dialect than used by a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
361
361
 
362
362
  ## Contributing
363
363
 
@@ -127,7 +127,7 @@ For more detail see [tests/test_fakes.py](tests/test_fakes.py)
127
127
  ## Caveats
128
128
 
129
129
  - The order of rows is non deterministic and may not match Snowflake unless ORDER BY is fully specified.
130
- - A more liberal Snowflake SQL dialect than a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
130
+ - A more liberal Snowflake SQL dialect than used by a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
131
131
 
132
132
  ## Contributing
133
133
 
@@ -630,7 +630,12 @@ class FakeSnowflakeConnection:
630
630
  df[col] = df[col].apply(lambda x: json.dumps(x) if isinstance(x, (dict, list)) else x)
631
631
 
632
632
  escaped_cols = ",".join(f'"{col}"' for col in df.columns.to_list())
633
- self._duck_conn.execute(f"INSERT INTO {table_name}({escaped_cols}) SELECT * FROM df")
633
+ name = table_name
634
+ if schema:
635
+ table_name = f"{schema}.{table_name}"
636
+ if database:
637
+ name = f"{database}.{table_name}"
638
+ self._duck_conn.execute(f"INSERT INTO {name}({escaped_cols}) SELECT * FROM df")
634
639
 
635
640
  return self._duck_conn.fetchall()[0][0]
636
641
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakesnow
3
- Version: 0.9.10
3
+ Version: 0.9.11
4
4
  Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -357,7 +357,7 @@ For more detail see [tests/test_fakes.py](tests/test_fakes.py)
357
357
  ## Caveats
358
358
 
359
359
  - The order of rows is non deterministic and may not match Snowflake unless ORDER BY is fully specified.
360
- - A more liberal Snowflake SQL dialect than a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
360
+ - A more liberal Snowflake SQL dialect than used by a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
361
361
 
362
362
  ## Contributing
363
363
 
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "fakesnow"
3
3
  description = "Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally."
4
- version = "0.9.10"
4
+ version = "0.9.11"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
7
7
  classifiers = ["License :: OSI Approved :: MIT License"]
@@ -1611,6 +1611,26 @@ def test_write_pandas_dict_different_keys(conn: snowflake.connector.SnowflakeCon
1611
1611
  assert indent(cur.fetchall()) == [('{\n "k": "v1"\n}',), ('{\n "k2": [\n "v\'2",\n "v\\"3"\n ]\n}',)]
1612
1612
 
1613
1613
 
1614
+ def test_write_pandas_db_schema(conn: snowflake.connector.SnowflakeConnection):
1615
+ with conn.cursor() as cur:
1616
+ cur.execute("create database db2")
1617
+ cur.execute("create schema db2.schema2")
1618
+ cur.execute("create or replace table db2.schema2.customers (ID int, FIRST_NAME varchar, LAST_NAME varchar)")
1619
+
1620
+ df = pd.DataFrame.from_records(
1621
+ [
1622
+ {"ID": 1, "FIRST_NAME": "Jenny"},
1623
+ {"ID": 2, "FIRST_NAME": "Jasper"},
1624
+ ]
1625
+ )
1626
+ snowflake.connector.pandas_tools.write_pandas(conn, df, "CUSTOMERS", "DB2", "SCHEMA2")
1627
+
1628
+ cur.execute("select id, first_name, last_name from db2.schema2.customers")
1629
+
1630
+ # columns not in dataframe will receive their default value
1631
+ assert cur.fetchall() == [(1, "Jenny", None), (2, "Jasper", None)]
1632
+
1633
+
1614
1634
  def indent(rows: Sequence[tuple] | Sequence[dict]) -> list[tuple]:
1615
1635
  # indent duckdb json strings tuple values to match snowflake json strings
1616
1636
  assert isinstance(rows[0], tuple)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes