-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsql_file.py
More file actions
24 lines (20 loc) · 731 Bytes
/
sql_file.py
File metadata and controls
24 lines (20 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from PyQt5.QtWidgets import QFileDialog
SQL_FILE_FILTER = "SQL files (*.sql)"
class SQLFile:
@staticmethod
def save(content: str):
filename, _ = QFileDialog \
.getSaveFileName(None, "Export data to CSV",
".",
SQL_FILE_FILTER, SQL_FILE_FILTER)
with open(filename, "a") as f:
f.writelines(content)
@staticmethod
def load():
filename, _ = QFileDialog \
.getOpenFileName(None, "Export data to CSV",
".",
SQL_FILE_FILTER, SQL_FILE_FILTER)
with open(filename, "r") as f:
data = f.readlines()
return "".join(data)