-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schemas combobox #840
Schemas combobox #840
Conversation
50b1144
to
053c044
Compare
connection = None | ||
try: | ||
connection = psycopg2.connect( | ||
dbname=self.pg_database_line_edit.text(), | ||
user=self.pg_auth_settings.username(), | ||
password=self.pg_auth_settings.password(), | ||
host=self.pg_host_line_edit.text(), | ||
port=self.pg_port_line_edit.text(), | ||
) | ||
|
||
except OperationalError as exception: | ||
logging.warning(f"Pg connection error: {exception}") | ||
return | ||
|
||
sql = """SELECT schema_name | ||
FROM information_schema.schemata; """ | ||
|
||
cursor = connection.cursor() | ||
cursor.execute(sql) | ||
|
||
schemas = cursor.fetchall() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... Maybe this would be nicer to go over the db_connector like most requests we perform on the database. Or are there any limitations?
db_connector = db_utils.get_db_connector(configuration)
if db_connector and db_connector.get_schema:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that but then I have seen that the pg_connector need a schema as parameter for the constructor.
But by re-looking at that I can just leave the schema empty... Will change this
@@ -440,3 +447,45 @@ def _keep_custom_settings(self): | |||
self.pg_ssl_mode_combo_box.currentData(), | |||
PgConfigPanel._SERVICE_COMBOBOX_ROLE.SSLMODE, | |||
) | |||
|
|||
def _fill_schema_combo_box(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this called? Is this called when I change the e.g. db name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the idea (but I have completely forgotten it in the end 🙈)
I will add a timer so that it isn't triggered continuosly during editation. Like it is done here
# refresh the models on changing values but avoid massive db connects by timer |
7001ad7
to
d8c3194
Compare
Remove debug print
I don't get why are the tests failing for 3.16... do you have any hint @signedav ? |
No idea. Maybe it's the 3.16 build. I would need to have a deeper look to find out... |
Ok thanks I'll try to find out... |
Maybe related to this qgis/QGIS#40567 But I wonder why it runs into it on this PR an not on the others... |
c9f12a7
to
1e800eb
Compare
@signedav in the last commit I replaced qgis 3.16 with 3.28 like in the library. Now all tests are passing. |
Cool. |
Postgres available schema list is read directly from the database and presented in a combo box. Still it is possible to manually entry a new schema name.
Fix #456
Depends on opengisch/QgisModelBakerLibrary#70