]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/db/connection.py
move table creation to jinja-based preprocessing
[nominatim.git] / nominatim / db / connection.py
index 12f5f4e15f8c55b57c5fc68b93154942a9839c3c..5aa05ced1ceb22cfb0c7e5ab218281ade9d0d18f 100644 (file)
@@ -75,6 +75,17 @@ class _Connection(psycopg2.extensions.connection):
         return True
 
 
+    def drop_table(self, name, if_exists=True):
+        """ Drop the table with the given name.
+            Set `if_exists` to False if a non-existant table should raise
+            an exception instead of just being ignored.
+        """
+        with self.cursor() as cur:
+            cur.execute("""DROP TABLE {} "{}"
+                        """.format('IF EXISTS' if if_exists else '', name))
+        self.commit()
+
+
     def server_version_tuple(self):
         """ Return the server version as a tuple of (major, minor).
             Converts correctly for pre-10 and post-10 PostgreSQL versions.