sqlym 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlym
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: SQL-first database access library for Python
5
5
  Author: izuno4t
6
6
  License-Expression: MIT
@@ -85,26 +85,30 @@ WHERE
85
85
  AND status = /* $status */'active'
86
86
  ```
87
87
 
88
- ### 3. Execute
88
+ ### 3. Parse and Execute
89
89
 
90
90
  ```python
91
- from sqlym import SqlExecutor, create_mapper
91
+ from sqlym import SqlLoader, parse_sql, create_mapper
92
92
 
93
- executor = SqlExecutor(connection)
93
+ # Load SQL template
94
+ loader = SqlLoader("sql")
95
+ sql_template = loader.load("employee/find_by_dept.sql")
96
+
97
+ # Parse with parameters (lines with None are automatically removed)
98
+ result = parse_sql(sql_template, {
99
+ "id": 100,
100
+ "dept_id": None, # this line is removed
101
+ "status": "active",
102
+ })
103
+
104
+ # Execute with your database driver
105
+ cursor.execute(result.sql, result.params)
106
+
107
+ # Map results to entity
94
108
  mapper = create_mapper(Employee)
109
+ employees = [mapper.map(row) for row in cursor.fetchall()]
95
110
 
96
- # Lines with None parameters are automatically removed
97
- result = executor.query(
98
- "sql/employee/find_by_dept.sql",
99
- {
100
- "id": 100,
101
- "dept_id": None,
102
- "status": "active",
103
- }, # dept_id line is removed
104
- mapper=mapper
105
- )
106
-
107
- for emp in result:
111
+ for emp in employees:
108
112
  print(emp.name)
109
113
  ```
110
114
 
@@ -154,7 +158,8 @@ If you want to hide the SQL snippet from error messages, disable it via
154
158
  config:
155
159
 
156
160
  ```python
157
- from sqlym import config
161
+ from sqlym.config import ERROR_INCLUDE_SQL, ERROR_MESSAGE_LANGUAGE
162
+ import sqlym.config as config
158
163
 
159
164
  config.ERROR_INCLUDE_SQL = False
160
165
  config.ERROR_MESSAGE_LANGUAGE = "en"
@@ -16,7 +16,7 @@ sqlym/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  sqlym/parser/line_unit.py,sha256=PlFCZ31O3LNQAHKzm-ccop_r2eP5bcqBuE4q9cY1dfA,796
17
17
  sqlym/parser/tokenizer.py,sha256=-eRWTt2EeEHSMV5OXtSJontmFHEDzxwJmSdaZNAwpx4,3051
18
18
  sqlym/parser/twoway.py,sha256=kg65LQw9OTefPv9VjpnOq_4Aw-AW_22Hk4NpNA68i8k,19538
19
- sqlym-0.1.0.dist-info/METADATA,sha256=1X3sOhCL62r-aefutL15sjHu7a152lZ9xXO5wz9I1qg,7137
20
- sqlym-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
21
- sqlym-0.1.0.dist-info/licenses/LICENSE,sha256=7vb-PbcXVPtaKh9PfRKbiAFPXA_zcRIfhE90vqCSF5A,1064
22
- sqlym-0.1.0.dist-info/RECORD,,
19
+ sqlym-0.1.1.dist-info/METADATA,sha256=yUaM7Ox1jc5KIePvpKnUob9Uy0ZXgfw4I_OTeMLOpfE,7402
20
+ sqlym-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
21
+ sqlym-0.1.1.dist-info/licenses/LICENSE,sha256=7vb-PbcXVPtaKh9PfRKbiAFPXA_zcRIfhE90vqCSF5A,1064
22
+ sqlym-0.1.1.dist-info/RECORD,,
File without changes