relations-sqlite3 0.6.11__tar.gz → 0.6.13__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relations-sqlite3
3
- Version: 0.6.11
3
+ Version: 0.6.13
4
4
  Summary: DB Modeling for SQLite using the sqlite3 library
5
5
  Home-page: https://github.com/relations-dil/python-relations-sqlite3
6
6
  Author: Gaffer Fitch
@@ -9,8 +9,8 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
- Requires-Dist: relations-dil>=0.6.18
13
- Requires-Dist: relations-sqlite>=0.6.4
12
+ Requires-Dist: relations-dil>=0.6.19
13
+ Requires-Dist: relations-sqlite>=0.6.5
14
14
  Dynamic: author
15
15
  Dynamic: author-email
16
16
  Dynamic: classifier
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relations-sqlite3
3
- Version: 0.6.11
3
+ Version: 0.6.13
4
4
  Summary: DB Modeling for SQLite using the sqlite3 library
5
5
  Home-page: https://github.com/relations-dil/python-relations-sqlite3
6
6
  Author: Gaffer Fitch
@@ -9,8 +9,8 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
- Requires-Dist: relations-dil>=0.6.18
13
- Requires-Dist: relations-sqlite>=0.6.4
12
+ Requires-Dist: relations-dil>=0.6.19
13
+ Requires-Dist: relations-sqlite>=0.6.5
14
14
  Dynamic: author
15
15
  Dynamic: author-email
16
16
  Dynamic: classifier
@@ -6,5 +6,4 @@ lib/relations_sqlite3.egg-info/PKG-INFO
6
6
  lib/relations_sqlite3.egg-info/SOURCES.txt
7
7
  lib/relations_sqlite3.egg-info/dependency_links.txt
8
8
  lib/relations_sqlite3.egg-info/requires.txt
9
- lib/relations_sqlite3.egg-info/top_level.txt
10
- test/test_relations_sqlite3.py
9
+ lib/relations_sqlite3.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ relations-dil>=0.6.19
2
+ relations-sqlite>=0.6.5
@@ -143,6 +143,19 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
143
143
 
144
144
  return query
145
145
 
146
+ @staticmethod
147
+ def write(cursor, model, sql, args):
148
+ """
149
+ Executes a write, a duplicate is relations' unique error, with the driver's error as its cause
150
+ """
151
+
152
+ try:
153
+ cursor.execute(sql, args)
154
+ except sqlite3.IntegrityError as exception:
155
+ if str(exception).startswith("UNIQUE constraint failed"):
156
+ raise relations.UniqueError(model, str(exception)) from exception
157
+ raise
158
+
146
159
  @staticmethod
147
160
  def create_id(cursor, model, query):
148
161
  """
@@ -150,7 +163,7 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
150
163
  """
151
164
 
152
165
  query.generate()
153
- cursor.execute(query.sql, tuple(query.args))
166
+ Source.write(cursor, model, query.sql, tuple(query.args))
154
167
 
155
168
  model[model._id] = cursor.lastrowid
156
169
 
@@ -170,7 +183,7 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
170
183
  else:
171
184
  create_query = query or self.create_query(model)
172
185
  create_query.generate()
173
- cursor.execute(create_query.sql, tuple(create_query.args))
186
+ self.write(cursor, model, create_query.sql, tuple(create_query.args))
174
187
 
175
188
  cursor.close()
176
189
 
@@ -391,14 +404,14 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
391
404
  rows = cursor.fetchall()
392
405
 
393
406
  if model._mode == "one" and len(rows) > 1:
394
- raise relations.ModelError(model, "more than one retrieved")
407
+ raise relations.MultipleError(model, "more than one retrieved")
395
408
 
396
409
  if model._mode == "one" and model._role != "child":
397
410
 
398
411
  if len(rows) < 1:
399
412
 
400
413
  if verify:
401
- raise relations.ModelError(model, "none retrieved")
414
+ raise relations.NotFoundError(model, "none retrieved")
402
415
  return None
403
416
 
404
417
  model._record = model._build("update", _read=self.values_retrieve(model, dict(rows[0])))
@@ -494,7 +507,7 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
494
507
  if update_query.SET.expressions:
495
508
 
496
509
  update_query.generate()
497
- cursor.execute(update_query.sql, update_query.args)
510
+ self.write(cursor, model, update_query.sql, update_query.args)
498
511
  updated += cursor.rowcount
499
512
 
500
513
  ties = model._record.tie({})
@@ -524,7 +537,7 @@ class Source(relations_sql.SOURCE, relations.Source): # pylint: disable=too-many
524
537
  if update_query.SET.expressions:
525
538
 
526
539
  update_query.generate()
527
- cursor.execute(update_query.sql, update_query.args)
540
+ self.write(cursor, updating, update_query.sql, update_query.args)
528
541
  updated += cursor.rowcount
529
542
 
530
543
 
@@ -20,8 +20,8 @@ setup(
20
20
  'relations_sqlite3'
21
21
  ],
22
22
  install_requires=[
23
- 'relations-dil>=0.6.18',
24
- 'relations-sqlite>=0.6.4'
23
+ 'relations-dil>=0.6.19',
24
+ 'relations-sqlite>=0.6.5'
25
25
  ],
26
26
  url="https://github.com/relations-dil/python-relations-sqlite3",
27
27
  author="Gaffer Fitch",
@@ -1,2 +0,0 @@
1
- relations-dil>=0.6.18
2
- relations-sqlite>=0.6.4