pudo / dataset

Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.
https://dataset.readthedocs.org/
MIT License
4.78k stars 298 forks source link

How can i get result from update and insert(using db.query) #259

Closed forkforlearn closed 6 years ago

forkforlearn commented 6 years ago

Hi ,when i try to us db.query , there is no message return, for example: db.query('update table set column1 = 123 when column2 = 222') or db.query('insert into table select * from table b')

stefanw commented 6 years ago

Both queries are not valid SQL and should result in a sqlite3.OperationalError.

OperationalError: (sqlite3.OperationalError) near "table": syntax error [SQL: 'insert into table select * from table b'] (Background on this error at: http://sqlalche.me/e/e3q8)

Concerning your queries: 1. there's no when keyword, use where. 2. don't mix insert and select statements.

But you should not run raw queries directly on the database before the structure is properly set up. Use the other dataset operations (e.g. table.insert) on tables to run your queries.