-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
61 lines (48 loc) · 1.77 KB
/
test.py
File metadata and controls
61 lines (48 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- encoding: utf-8 -*-
"""
@File : test_xlwt.py
@Contact : 2656537241@qq.com
@License : (C)Copyright 2018-2021
@Modify Time @Author @Version @Desciption
------------ ------- -------- -----------
2023/8/7 18:27 Ruier 1.0 None
"""
import sys
from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt.QtCore import Qt
from qgis.core import QgsApplication
from src.widgets.mainwindow import MainWindow
def qtapp():
app = QApplication(sys.argv)
mainwWD = MainWindow()
mainwWD.show()
sys.exit(app.exec_())
def qgisapp():
QgsApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QgsApplication([],True,platformName="desktop")
app.initQgis()
app.setStyle("Cividis")
mainWD = MainWindow()
mainWD.show()
app.exitQgis()
app.exec_()
print("正常退出")
def load_spatiallite():
import sqlite3 as sqlite
with sqlite.connect("test.sqlite")as conn:
conn.enable_load_extension(True)
conn.execute("SELECT load_extension('mod_spatialite')")
print("Loading spatialite finish")
cursor = conn.cursor()
# cursor.execute('''CREATE TABLE test(id INTEGER PRIMARY KEY, name TEXT, geom BLOB);''')
# cursor.execute('''SELECT AddGeometryColumn('test', 'geom', 4326, 'Point', 'XY');''')
# 插入一些数据
cursor.execute('''INSERT INTO test(name, geom) VALUES(?, ?)''', ('foo', 'POINT (10 20)')) # 可以替换为你的数据和坐标
cursor.execute('''INSERT INTO test(name, geom) VALUES(?, ?)''', ('bar', 'POINT (30 40)')) # 可以替换为你的数据和坐标
# 提交事务以保存更改
conn.commit()
# cursor.close()
# conn.close()
if __name__ == '__main__':
# qgisapp()
load_spatiallite()