-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheric7_sqlbrowser.py
More file actions
111 lines (85 loc) · 2.61 KB
/
Copy patheric7_sqlbrowser.py
File metadata and controls
111 lines (85 loc) · 2.61 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2009 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#
"""
eric SQL Browser.
This is the main Python script that performs the necessary initialization
of the SQL browser and starts the Qt event loop.
"""
import argparse
import os
import sys
from PyQt6.QtGui import QGuiApplication
def createArgparseNamespace():
"""
Function to create an argument parser.
@return created argument parser object
@rtype argparse.ArgumentParser
"""
from eric7.__version__ import Version
# 1. create the argument parser
parser = argparse.ArgumentParser(
description="Graphical tool of the eric tool suite to inspect SQL databases.",
epilog="Copyright (c) 2009 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>.",
)
# 2. add the arguments
parser.add_argument(
"-V",
"--version",
action="version",
version="%(prog)s {0}".format(Version),
help="show version information and exit",
)
parser.add_argument(
"--config",
metavar="config_dir",
help="use the given directory as the one containing the config files",
)
parser.add_argument(
"--settings",
metavar="settings_dir",
help="use the given directory to store the settings files",
)
parser.add_argument(
"connection",
nargs="*",
default=[],
help="database connection string",
)
# 3. create the Namespace object by parsing the command line
args = parser.parse_args()
return args
args = createArgparseNamespace()
if args.config:
from eric7 import EricUtilities
EricUtilities.setConfigDir(args.config)
if args.settings:
from PyQt6.QtCore import QSettings
SettingsDir = os.path.expanduser(args.settings)
if not os.path.isdir(SettingsDir):
os.makedirs(SettingsDir)
QSettings.setPath(
QSettings.Format.IniFormat, QSettings.Scope.UserScope, SettingsDir
)
from eric7.Toolbox import Startup
def createMainWidget(args):
"""
Function to create the main widget.
@param args namespace object containing the parsed command line parameters
@type argparse.Namespace
@return reference to the main widget
@rtype QWidget
"""
from eric7.SqlBrowser.SqlBrowser import SqlBrowser
browser = SqlBrowser(args.connection)
return browser
def main():
"""
Main entry point into the application.
"""
QGuiApplication.setDesktopFileName("eric7_sqlbrowser")
res = Startup.appStartup(args, createMainWidget)
sys.exit(res)
if __name__ == "__main__":
main()