pamhyr: Rename '_sql_*' function to '_db_*'.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-27 14:15:42 +02:00
1 parent 8d92fbbdac
commit ea2dbfba3e
23 files changed
+186 -186

No files matched your search

+5 -5
View File
@@ -36,7 +36,7 @@ class PointXYZ(Point, SQLSubModel):
self._z = float(z)
@classmethod
def _sql_create(cls, execute):
def _db_create(cls, execute):
execute("""
CREATE TABLE geometry_pointXYZ(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -55,7 +55,7 @@ class PointXYZ(Point, SQLSubModel):
return cls._create_submodel(execute)
@classmethod
def _sql_update(cls, execute, version):
def _db_update(cls, execute, version):
cls._update_submodel(execute, version)
major, minor, release = version.strip().split(".")
@@ -71,7 +71,7 @@ class PointXYZ(Point, SQLSubModel):
return True
@classmethod
def _sql_load(cls, execute, data=None):
def _db_load(cls, execute, data=None):
status = data["status"]
profile = data["profile"]
@@ -109,7 +109,7 @@ class PointXYZ(Point, SQLSubModel):
yield ind, new
def _sql_save(self, execute, data=None):
def _db_save(self, execute, data=None):
profile = data["profile"]
ind = data["ind"]
@@ -119,7 +119,7 @@ class PointXYZ(Point, SQLSubModel):
"INSERT OR REPLACE INTO " +
"geometry_pointXYZ(ind, name, x, y, z, profile, sl) " +
"VALUES (" +
f"{ind}, '{self._sql_format(self._name)}', " +
f"{ind}, '{self._db_format(self._name)}', " +
f"{self.x}, {self.y}, {self.z}, " +
f"{profile.id}, {sl}" +
")"
+7 -7
View File
@@ -69,7 +69,7 @@ class ProfileXYZ(Profile, SQLSubModel):
)
@classmethod
def _sql_create(cls, execute):
def _db_create(cls, execute):
execute("""
CREATE TABLE geometry_profileXYZ(
id INTEGER NOT NULL PRIMARY KEY,
@@ -89,7 +89,7 @@ class ProfileXYZ(Profile, SQLSubModel):
return cls._create_submodel(execute)
@classmethod
def _sql_update(cls, execute, version):
def _db_update(cls, execute, version):
major, minor, release = version.strip().split(".")
if major == minor == "0":
if int(release) < 2:
@@ -104,7 +104,7 @@ class ProfileXYZ(Profile, SQLSubModel):
return cls._update_submodel(execute, version)
@classmethod
def _sql_load(cls, execute, data=None):
def _db_load(cls, execute, data=None):
profiles = []
status = data["status"]
reach = data["reach"]
@@ -147,7 +147,7 @@ class ProfileXYZ(Profile, SQLSubModel):
)
data["profile"] = new
new._points = PointXYZ._sql_load(execute, data.copy())
new._points = PointXYZ._db_load(execute, data.copy())
yield ind, new
@@ -155,7 +155,7 @@ class ProfileXYZ(Profile, SQLSubModel):
# return profiles
def _sql_save(self, execute, data=None):
def _db_save(self, execute, data=None):
ok = True
ind = data["ind"]
@@ -166,7 +166,7 @@ class ProfileXYZ(Profile, SQLSubModel):
"geometry_profileXYZ(id, ind, name, reach, " +
"kp, num, code1, code2, sl) " +
"VALUES (" +
f"{self.id}, {ind}, '{self._sql_format(self._name)}', " +
f"{self.id}, {ind}, '{self._db_format(self._name)}', " +
f"{self.reach.id}, {self.kp}, {self.num}, " +
f"{self.code1}, {self.code1}, {sl}" +
")"
@@ -179,7 +179,7 @@ class ProfileXYZ(Profile, SQLSubModel):
ind = 0
for point in self.points:
data["ind"] = ind
ok &= point._sql_save(execute, data)
ok &= point._db_save(execute, data)
ind += 1
return ok
+6 -6
View File
@@ -52,25 +52,25 @@ class Reach(SQLSubModel):
self._guidelines = {}
@classmethod
def _sql_create(cls, execute):
def _db_create(cls, execute):
return cls._create_submodel(execute)
@classmethod
def _sql_update(cls, execute, version):
def _db_update(cls, execute, version):
return cls._update_submodel(execute, version)
@classmethod
def _sql_load(cls, execute, data=None):
def _db_load(cls, execute, data=None):
new = cls(status=data["status"], parent=data["parent"])
new._profiles = ProfileXYZ._sql_load(
new._profiles = ProfileXYZ._db_load(
execute,
data=data
)
return new
def _sql_save(self, execute, data=None):
def _db_save(self, execute, data=None):
# Delete old data
execute(f"DELETE FROM geometry_profileXYZ WHERE reach = {self.id}")
# execute(f"DELETE FROM geometry_pointXYZ")
@@ -81,7 +81,7 @@ class Reach(SQLSubModel):
ind = 0
for profile in self.profiles:
data["ind"] = ind
profile._sql_save(execute, data)
profile._db_save(execute, data)
ind += 1
return True