Newer
Older
import os
import sqlite3
from pathlib import Path
from sqlite3 import Error
cwd = Path(os.path.dirname(os.path.abspath(__file__)))
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):
""" create a database connection to a SQLite database """
try:
conn = sqlite3.connect(db_file)
conn.enable_load_extension(True)
conn.load_extension("mod_spatialite")
print(sqlite3.version)
except Error as e:
print(e)
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)