Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Temperaturverteilung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s39174
Temperaturverteilung
Commits
488fbc65
Commit
488fbc65
authored
3 years ago
by
Clemens Berteld
Browse files
Options
Downloads
Patches
Plain Diff
SpatiaLite working
parent
7830f92c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataacquisition/sandbox_sqlite.py
+15
-6
15 additions, 6 deletions
dataacquisition/sandbox_sqlite.py
with
15 additions
and
6 deletions
dataacquisition/sandbox_sqlite.py
+
15
−
6
View file @
488fbc65
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment