Comments (3)
Nothing to do with TypesConverterCursorFactory
which you can see if you comment out setting it as cursor_factory
.
Virtual tables are a SQLite thing which means they only operate on SQLite supported data types. I've changed the error message, so now you get this as the last line of the exception:
TypeError: Value from Python is not supported by SQLite. It should be one of None, int, float, str, or bytes. Received complex.
There is a repr_invalid
parameter to make_virtual_table which would have turned the complex number into the string '(3+4j)'
but that is repr output and not something the types converter would understand. The parameter is off by default because it is expensive checking every value in every column of every row returned.
You could change the yield line to this which would convert the value into something SQLite supports.
yield {"col1": registrar.adapt_value(table_data[c])}
But then on running you will get this where the values are the adapted ones (strings).
┌──────────┐
│ col1 │
│ 3.0+4.0 │
│ 8.0+-2.0 │
│ 1.0+-5.0 │
└──────────┘
The reason for that is the virtual table at the SQLite level does not have declared column types. Using apsw.ext.query_info will include this where the None
is the declared column type:
description=(('col1', None),),
In short, this is trying really hard to pretend SQLite supports COMPLEX but that has to be done everywhere. If the yield
line was changed and make_virtual_table
did declare the column at the SQLite level to have type COMPLEX
then it would work. But the latter is not something that will be changed in apsw because the library code is applicable to everyone.
You can however do it yourself. You can copy make_virtual_table
, and where it gets the function signature you have to look at the annotation and turn that into whatever string you want in the SQL that creates the virtual table.
from apsw.
Thinking about it a little more, I'd recommend you avoid make_virtual_table
and implement your own virtual tables. That will provide precise control over exactly what values are provided to SQLite, as well as the table and column declarations for the virtual table which are necessary for TypesConverterCursorFactory
to work as expected.
from apsw.
Will do. Thanks for your help!
from apsw.
Related Issues (20)
- Unknown apsw attribute 'SQLiteValues' HOT 3
- Cursor.executemany should be annotated as accepting Iterable[Bindings] instead of Sequence[Bindings] HOT 1
- Implement Unicode TR-29 and TR-14 HOT 1
- error: static declaration of ‘PyLong_AsInt’ in Python 3.13+ HOT 3
- Switch to cosign for signing
- Incorrect values in `colUsed` HOT 2
- Update to Unicode 16.0 when released September 2024 HOT 2
- connection.set_row_trace - excepts; Connection.setrowtrace works HOT 4
- `connection.setrowtrace` stops working when adapters are registered HOT 5
- Datetimes into sqlite via APSW HOT 1
- Revise logging levels
- query execution row and time limits HOT 1
- Support subtypes in functions
- Don't cache pragmas
- con.pragma can't accept blobs HOT 1
- Update Connection.pragma with schema parameter
- Implement SQLITE_FCNTL_VFSNAME
- VFS xRandomness errors need to be unraisable HOT 1
- apsw.ext.query_info should find bound parameters
- Comprehensive dump module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apsw.