Does

.pragma table_info(<tablename>);

not solve your problem?

-----Ursprüngliche Nachricht-----
Von: sqlite-users-boun...@mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Rapin 
Patrick
Gesendet: Freitag, 17. Juni 2016 10:57
An: sqlite-users@mailinglists.sqlite.org
Betreff: [sqlite] sqlite3_column_origin_name for INSERT and UPDATE

Hello,

I am using function sqlite3_column_origin_name and friends in my SQLite3 C++ 
wrapper class to get table and column names in SELECT statements.
I would like to have the same feature for INSERT and UPDATE statements: that 
is, find the table name and column names when writing to the database, not only 
reading.
I think this is impossible with current SQLite3 library, but I may be missing 
something.
The workaround I have implemented is to use some C++11 regular expressions to 
parse the SQL expression outside of SQLite3.
What would be the difficulty to support origin column names also for writing, 
not just reading ?

_______

In background, I will explain the reason I would like such feature.
I know that there are already plenty of C++ wrappers over SQLite3, but I wrote 
another one for our company base framework.
I think it has plenty of qualities:
simple: essentially a single function, executeQuery, using a variadic signature 
like printf (but type safe, thanks to C++11 variadic templates !) automatic 
caching of instructions (does not recompile same SQL expression if already in 
the cache) automatic binding of both input and output arguments
fast: the overhead over calling manually SQLite3 functions is minimum natively 
support the C++ base classes of our framework (also a drawback: I could not 
distribute that wrapper by itself) have a limited support for units in numeric 
values.

The last point is the reason for my request. For example, if a table was 
created with that command:

CREATE TABLE t1 (speed REAL_m_per_s);

SQLite3 will assign to speed column an affinity of floating point value since 
it has REAL in the type.
And my C++ wrapper then knows that this column is a speed expressed in meters 
per second.
So when making a SELECT on t1 table, the wrapper will output number objects 
with unit dimension of Speed expressed in m/s !

To be complete, I want to check when writing to database (UPDATE or INSERT) 
that the unit contained in the input values match the expected type of the 
column.
Possibly making unit conversion on the fly (m -> ft).
But for that, I need to find out the column names and table name implied in a 
UPDATE or INSERT statement.

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to