Re: [QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-12-04 Thread Raymond Nijssen via QGIS-Developer

Thanks Nyall, will try this today!

Raymond



On 05-12-2022 00:53, Nyall Dawson wrote:

On Fri, 2 Dec 2022 at 23:05, Richard Duivenvoorde via QGIS-Developer
 wrote:


Ok, I think I found the crux!

With your code QGIS 3.26 will CREATE a new geopackage... (if it is not there 
yet)
After which QGIS master is fine

BUT QGIS master apparently does NOT create a new geopackage with your code...
So IF there is an excisting test.gpkg, all is fine
IF there is not one, it depends on you QGIS version if it creates a fresh one 
or not?

Maybe some core dev can say something about this?


I'd say the old behaviour was an unintentional bug, and that
createConnection should only be used with a path that already exists.

For 3.28 and later you can create empty databases using
QgsProviderMetadata.createDatabase(uri), eg:

QgsProviderRegistry.instance().providerMetadata('ogr').createDatabase('/path/to/data.gpkg')

After that you can create a connection to the db using createConnection safely.

Nyall





Regards,

Richard Duivenvoorde

On 12/2/22 13:53, Richard Duivenvoorde via QGIS-Developer wrote:

Hi Raymond,

I've updated your test script a little:

gpkg_fn = '/tmp/test.gpkg'
try:
  print(QgsProviderRegistry.instance().providerList())
  md = QgsProviderRegistry.instance().providerMetadata('ogr')
  print(f'md = {md}')
  conn = md.createConnection(gpkg_fn, {})
  print(f'conn = {conn}')
  fields = QgsFields()
  fields.append(QgsField('key', QVariant.String))
  fields.append(QgsField('value', QVariant.String))
  conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})
except Exception as e:
  print(f'ERROR: {e}')

As said: in my freshly compiled master, this fails to run with 'Could not 
retrieve driver for connection'
It also fails on my 3.28.0 version I have in a Windows VM.

It DOES print the 'ogr' driver in the providerList() though.

Strange behaviour: after starting (the older compiled) Qgis 3.26 on the same 
Linux system (in 3.26 the script always seems to work...) QGIS master ALSO 
works!!!

So I thought it had something todo with loading different provider registries 
or so?
Maybe master not having something but after starting 3.26 it was there?
Or is it loading (different) gdal/ogr libs order?
Did something change there?

Looking that the createConnection docs:
https://qgis.org/pyqgis/master/core/QgsConnectionRegistry.html#qgis.core.QgsConnectionRegistry.createConnection
I thought to see that your 'id' was only the filename, but adding ogr:// in 
front of it does not even work...
So not sure if that createConnection doc is old, or if I'm looking in the wrong 
createConnection...

Anybody can





On 12/2/22 12:30, Raymond Nijssen via QGIS-Developer wrote:

No one having a clue? Should I create an issue?

Raymond


On 30-11-2022 18:08, Raymond Nijssen via QGIS-Developer wrote:

Hi developers,

Recently some users of my plugin started getting errors in the code that 
creates a .gpkg file with a table. I wrote a piece of test code:

gpkg_fn = '/home/raymond/tmp/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(gpkg_fn, {})
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})


That last line *sometimes* results in this error:

_core.QgsProviderConnectionException: Could not retrieve driver for connection



I cannot reproduce the error on my laptop (Linux), but Richard tried a few QGIS 
versions in both Windows and Linux and *sometimes* got the error and sometimes 
not. Even in the same application, the error disappeared after running another 
version of QGIS simultaneously... :/

No clue if this error is GDAL or Qt or whatever related, pretty puzzling for 
me. Hope anyone can help!

Kind regards,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-12-04 Thread Nyall Dawson via QGIS-Developer
On Fri, 2 Dec 2022 at 23:05, Richard Duivenvoorde via QGIS-Developer
 wrote:
>
> Ok, I think I found the crux!
>
> With your code QGIS 3.26 will CREATE a new geopackage... (if it is not there 
> yet)
> After which QGIS master is fine
>
> BUT QGIS master apparently does NOT create a new geopackage with your code...
> So IF there is an excisting test.gpkg, all is fine
> IF there is not one, it depends on you QGIS version if it creates a fresh one 
> or not?
>
> Maybe some core dev can say something about this?

I'd say the old behaviour was an unintentional bug, and that
createConnection should only be used with a path that already exists.

For 3.28 and later you can create empty databases using
QgsProviderMetadata.createDatabase(uri), eg:

QgsProviderRegistry.instance().providerMetadata('ogr').createDatabase('/path/to/data.gpkg')

After that you can create a connection to the db using createConnection safely.

Nyall



>
> Regards,
>
> Richard Duivenvoorde
>
> On 12/2/22 13:53, Richard Duivenvoorde via QGIS-Developer wrote:
> > Hi Raymond,
> >
> > I've updated your test script a little:
> >
> > gpkg_fn = '/tmp/test.gpkg'
> > try:
> >  print(QgsProviderRegistry.instance().providerList())
> >  md = QgsProviderRegistry.instance().providerMetadata('ogr')
> >  print(f'md = {md}')
> >  conn = md.createConnection(gpkg_fn, {})
> >  print(f'conn = {conn}')
> >  fields = QgsFields()
> >  fields.append(QgsField('key', QVariant.String))
> >  fields.append(QgsField('value', QVariant.String))
> >  conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
> > QgsCoordinateReferenceSystem(), True, {})
> > except Exception as e:
> >  print(f'ERROR: {e}')
> >
> > As said: in my freshly compiled master, this fails to run with 'Could not 
> > retrieve driver for connection'
> > It also fails on my 3.28.0 version I have in a Windows VM.
> >
> > It DOES print the 'ogr' driver in the providerList() though.
> >
> > Strange behaviour: after starting (the older compiled) Qgis 3.26 on the 
> > same Linux system (in 3.26 the script always seems to work...) QGIS master 
> > ALSO works!!!
> >
> > So I thought it had something todo with loading different provider 
> > registries or so?
> > Maybe master not having something but after starting 3.26 it was there?
> > Or is it loading (different) gdal/ogr libs order?
> > Did something change there?
> >
> > Looking that the createConnection docs:
> > https://qgis.org/pyqgis/master/core/QgsConnectionRegistry.html#qgis.core.QgsConnectionRegistry.createConnection
> > I thought to see that your 'id' was only the filename, but adding ogr:// in 
> > front of it does not even work...
> > So not sure if that createConnection doc is old, or if I'm looking in the 
> > wrong createConnection...
> >
> > Anybody can
> >
> >
> >>>
> > On 12/2/22 12:30, Raymond Nijssen via QGIS-Developer wrote:
> >> No one having a clue? Should I create an issue?
> >>
> >> Raymond
> >>
> >>
> >> On 30-11-2022 18:08, Raymond Nijssen via QGIS-Developer wrote:
> >>> Hi developers,
> >>>
> >>> Recently some users of my plugin started getting errors in the code that 
> >>> creates a .gpkg file with a table. I wrote a piece of test code:
> >>>
> >>> gpkg_fn = '/home/raymond/tmp/test.gpkg'
> >>> md = QgsProviderRegistry.instance().providerMetadata('ogr')
> >>> conn = md.createConnection(gpkg_fn, {})
> >>> fields = QgsFields()
> >>> fields.append(QgsField('key', QVariant.String))
> >>> fields.append(QgsField('value', QVariant.String))
> >>> conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
> >>> QgsCoordinateReferenceSystem(), True, {})
> >>>
> >>>
> >>> That last line *sometimes* results in this error:
> >>>
> >>> _core.QgsProviderConnectionException: Could not retrieve driver for 
> >>> connection
> >>>
> >>>
> >>>
> >>> I cannot reproduce the error on my laptop (Linux), but Richard tried a 
> >>> few QGIS versions in both Windows and Linux and *sometimes* got the error 
> >>> and sometimes not. Even in the same application, the error disappeared 
> >>> after running another version of QGIS simultaneously... :/
> >>>
> >>> No clue if this error is GDAL or Qt or whatever related, pretty puzzling 
> >>> for me. Hope anyone can help!
> >>>
> >>> Kind regards,
> >>> Raymond
> >>> ___
> >>> QGIS-Developer mailing list
> >>> QGIS-Developer@lists.osgeo.org
> >>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> ___
> >> QGIS-Developer mailing list
> >> QGIS-Developer@lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
> > ___
> > QGIS-Developer mailing list
> > QGIS-Developer@lists.osgeo.org
> > List info: https://lists.osgeo.org/mai

Re: [QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-12-02 Thread Richard Duivenvoorde via QGIS-Developer

Ok, I think I found the crux!

With your code QGIS 3.26 will CREATE a new geopackage... (if it is not there 
yet)
After which QGIS master is fine

BUT QGIS master apparently does NOT create a new geopackage with your code...
So IF there is an excisting test.gpkg, all is fine
IF there is not one, it depends on you QGIS version if it creates a fresh one 
or not?

Maybe some core dev can say something about this?

Regards,

Richard Duivenvoorde

On 12/2/22 13:53, Richard Duivenvoorde via QGIS-Developer wrote:

Hi Raymond,

I've updated your test script a little:

gpkg_fn = '/tmp/test.gpkg'
try:
     print(QgsProviderRegistry.instance().providerList())
     md = QgsProviderRegistry.instance().providerMetadata('ogr')
     print(f'md = {md}')
     conn = md.createConnection(gpkg_fn, {})
     print(f'conn = {conn}')
     fields = QgsFields()
     fields.append(QgsField('key', QVariant.String))
     fields.append(QgsField('value', QVariant.String))
     conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})
except Exception as e:
     print(f'ERROR: {e}')

As said: in my freshly compiled master, this fails to run with 'Could not 
retrieve driver for connection'
It also fails on my 3.28.0 version I have in a Windows VM.

It DOES print the 'ogr' driver in the providerList() though.

Strange behaviour: after starting (the older compiled) Qgis 3.26 on the same 
Linux system (in 3.26 the script always seems to work...) QGIS master ALSO 
works!!!

So I thought it had something todo with loading different provider registries 
or so?
Maybe master not having something but after starting 3.26 it was there?
Or is it loading (different) gdal/ogr libs order?
Did something change there?

Looking that the createConnection docs:
https://qgis.org/pyqgis/master/core/QgsConnectionRegistry.html#qgis.core.QgsConnectionRegistry.createConnection
I thought to see that your 'id' was only the filename, but adding ogr:// in 
front of it does not even work...
So not sure if that createConnection doc is old, or if I'm looking in the wrong 
createConnection...

Anybody can





On 12/2/22 12:30, Raymond Nijssen via QGIS-Developer wrote:

No one having a clue? Should I create an issue?

Raymond


On 30-11-2022 18:08, Raymond Nijssen via QGIS-Developer wrote:

Hi developers,

Recently some users of my plugin started getting errors in the code that 
creates a .gpkg file with a table. I wrote a piece of test code:

gpkg_fn = '/home/raymond/tmp/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(gpkg_fn, {})
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})


That last line *sometimes* results in this error:

_core.QgsProviderConnectionException: Could not retrieve driver for connection



I cannot reproduce the error on my laptop (Linux), but Richard tried a few QGIS 
versions in both Windows and Linux and *sometimes* got the error and sometimes 
not. Even in the same application, the error disappeared after running another 
version of QGIS simultaneously... :/

No clue if this error is GDAL or Qt or whatever related, pretty puzzling for 
me. Hope anyone can help!

Kind regards,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-12-02 Thread Richard Duivenvoorde via QGIS-Developer

Hi Raymond,

I've updated your test script a little:

gpkg_fn = '/tmp/test.gpkg'
try:
print(QgsProviderRegistry.instance().providerList())
md = QgsProviderRegistry.instance().providerMetadata('ogr')
print(f'md = {md}')
conn = md.createConnection(gpkg_fn, {})
print(f'conn = {conn}')
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})
except Exception as e:
print(f'ERROR: {e}')

As said: in my freshly compiled master, this fails to run with 'Could not 
retrieve driver for connection'
It also fails on my 3.28.0 version I have in a Windows VM.

It DOES print the 'ogr' driver in the providerList() though.

Strange behaviour: after starting (the older compiled) Qgis 3.26 on the same 
Linux system (in 3.26 the script always seems to work...) QGIS master ALSO 
works!!!

So I thought it had something todo with loading different provider registries 
or so?
Maybe master not having something but after starting 3.26 it was there?
Or is it loading (different) gdal/ogr libs order?
Did something change there?

Looking that the createConnection docs:
https://qgis.org/pyqgis/master/core/QgsConnectionRegistry.html#qgis.core.QgsConnectionRegistry.createConnection
I thought to see that your 'id' was only the filename, but adding ogr:// in 
front of it does not even work...
So not sure if that createConnection doc is old, or if I'm looking in the wrong 
createConnection...

Anybody can





On 12/2/22 12:30, Raymond Nijssen via QGIS-Developer wrote:

No one having a clue? Should I create an issue?

Raymond


On 30-11-2022 18:08, Raymond Nijssen via QGIS-Developer wrote:

Hi developers,

Recently some users of my plugin started getting errors in the code that 
creates a .gpkg file with a table. I wrote a piece of test code:

gpkg_fn = '/home/raymond/tmp/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(gpkg_fn, {})
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})


That last line *sometimes* results in this error:

_core.QgsProviderConnectionException: Could not retrieve driver for connection



I cannot reproduce the error on my laptop (Linux), but Richard tried a few QGIS 
versions in both Windows and Linux and *sometimes* got the error and sometimes 
not. Even in the same application, the error disappeared after running another 
version of QGIS simultaneously... :/

No clue if this error is GDAL or Qt or whatever related, pretty puzzling for 
me. Hope anyone can help!

Kind regards,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-12-02 Thread Raymond Nijssen via QGIS-Developer

No one having a clue? Should I create an issue?

Raymond


On 30-11-2022 18:08, Raymond Nijssen via QGIS-Developer wrote:

Hi developers,

Recently some users of my plugin started getting errors in the code that 
creates a .gpkg file with a table. I wrote a piece of test code:


gpkg_fn = '/home/raymond/tmp/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(gpkg_fn, {})
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})



That last line *sometimes* results in this error:

_core.QgsProviderConnectionException: Could not retrieve driver for 
connection




I cannot reproduce the error on my laptop (Linux), but Richard tried a 
few QGIS versions in both Windows and Linux and *sometimes* got the 
error and sometimes not. Even in the same application, the error 
disappeared after running another version of QGIS simultaneously... :/


No clue if this error is GDAL or Qt or whatever related, pretty puzzling 
for me. Hope anyone can help!


Kind regards,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] createvectorTable error: Could not retrieve driver for connection

2022-11-30 Thread Raymond Nijssen via QGIS-Developer

Hi developers,

Recently some users of my plugin started getting errors in the code that 
creates a .gpkg file with a table. I wrote a piece of test code:


gpkg_fn = '/home/raymond/tmp/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(gpkg_fn, {})
fields = QgsFields()
fields.append(QgsField('key', QVariant.String))
fields.append(QgsField('value', QVariant.String))
conn.createVectorTable('', 'test', fields, QgsWkbTypes.NoGeometry, 
QgsCoordinateReferenceSystem(), True, {})



That last line *sometimes* results in this error:

_core.QgsProviderConnectionException: Could not retrieve driver for 
connection




I cannot reproduce the error on my laptop (Linux), but Richard tried a 
few QGIS versions in both Windows and Linux and *sometimes* got the 
error and sometimes not. Even in the same application, the error 
disappeared after running another version of QGIS simultaneously... :/


No clue if this error is GDAL or Qt or whatever related, pretty puzzling 
for me. Hope anyone can help!


Kind regards,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer