Skip to content
Snippets Groups Projects
Commit 488fbc65 authored by Clemens Berteld's avatar Clemens Berteld
Browse files

SpatiaLite working

parent 7830f92c
No related branches found
No related tags found
No related merge requests found
...@@ -2,21 +2,30 @@ import os ...@@ -2,21 +2,30 @@ import os
import sqlite3 import sqlite3
from pathlib import Path from pathlib import Path
from sqlite3 import Error from sqlite3 import Error
cwd = Path(os.path.dirname(os.path.abspath(__file__))) cwd = Path(os.path.dirname(os.path.abspath(__file__)))
print(cwd) spatialite_path = 'D:/Uni/Master/01_SS2021/Automatisierte_Geodatenprozessierung/temperaturverteilung/dataacquisition/mod_spatialite-5.0.1-win-amd64'
os.environ['PATH'] = spatialite_path + ';' + os.environ['PATH']
def create_connection(db_file): def create_connection(db_file):
""" create a database connection to a SQLite database """ """ create a database connection to a SQLite database """
conn = None
try: try:
conn = sqlite3.connect(db_file) conn = sqlite3.connect(db_file)
conn.enable_load_extension(True)
conn.load_extension("mod_spatialite")
print(sqlite3.version) print(sqlite3.version)
return conn
except Error as e: except Error as e:
print(e) print(e)
finally:
if conn:
conn.close()
create_connection('temperatures.db') # ':memory:' for saving in RAM connection = create_connection('temperatures.db') # ':memory:' for saving in RAM
try:
c = connection.cursor()
# c.execute("CREATE TABLE test (id INTEGER);")
# c.execute("select * from test;")
print(c.fetchall())
except Error as e:
print(e)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment