Skip to content
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

Merged
merged 6 commits into from
Nov 17, 2023
Merged

Schemas combobox #840

merged 6 commits into from
Nov 17, 2023

Conversation

domi4484
Copy link
Member

@domi4484 domi4484 commented Nov 9, 2023

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

image

@domi4484 domi4484 requested a review from signedav November 9, 2023 13:39
Comment on lines 452 to 472
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()
Copy link
Member

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:     

Copy link
Member Author

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):
Copy link
Member

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?

Copy link
Member Author

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

@domi4484
Copy link
Member Author

domi4484 commented Nov 12, 2023

I don't get why are the tests failing for 3.16... do you have any hint @signedav ?

@signedav
Copy link
Member

No idea. Maybe it's the 3.16 build. I would need to have a deeper look to find out...

@domi4484
Copy link
Member Author

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...

@signedav
Copy link
Member

Maybe related to this qgis/QGIS#40567 But I wonder why it runs into it on this PR an not on the others...

@domi4484
Copy link
Member Author

@signedav in the last commit I replaced qgis 3.16 with 3.28 like in the library. Now all tests are passing.
I did one more try and ran the plugin on QGIS 3.16, from a quick test everything seems to work normally....

@signedav
Copy link
Member

Cool.

@signedav signedav merged commit 1356f60 into master Nov 17, 2023
6 checks passed
@signedav signedav deleted the schemasCombobox branch November 17, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combobox for schemas when exporting
2 participants