sqlite

Replacing value in all cursor rows

萝らか妹 提交于 2021-02-19 03:08:06
问题 Using SQLite and Python 3.1, I want to display currency data in a HTML table via. a template which accepts a cursor as a parameter. Hence all currency values must have 2 decimal places, but SQLite stores them as float type (even though the structure states decimal :-( ) so some must be converted before display (eg. I want 12.1 displayed as 12.10). The code goes something like this (simplified for illustration)... import sqlite3 con = sqlite3.connect("mydb") con.row_factory = sqlite3.Row cur =

Sqlite version for Python 3.x

旧城冷巷雨未停 提交于 2021-02-19 02:42:08
问题 I want to use sqlite3 with Python 3.1.3 and I need to set enable_load_extension to true. To do this I believe I need sqlite version 3.x. From reading posts here it looks like a suitable version of sqlite ought to be bundled with python version 2.6 and up. However, when I do: import sqlite3 sqlite3.version_info The result returned is: '2.4.1' I get the same answer on a different machine running Python 2.6. The pysqlite site has no binaries for Python 3.x. My copy of Python came from the

How should I use Sqlite “PRAGMA integrity_check” in C

对着背影说爱祢 提交于 2021-02-19 02:29:10
问题 I have corrupted database. In commandline I typed PRAGMA integrity_check and sqlite returned On tree page 441 cell 17: Rowid 205 out of order (min less than parent max of 12258) On tree page 26 cell 12: 2nd reference to page 441 On tree page 26 cell 12: Child page depth differs On tree page 26 cell 13: Child page depth differs Page 65 is never used Page 66 is never used wrong # of entries in index sqlite_autoindex_TBL_1 In my c program I typed sqlite3 *glbDBHandle; sqlite3_open(DB_FILE,

Remove Unique constraint on a column in sqlite database

家住魔仙堡 提交于 2021-02-19 02:24:06
问题 I am trying to remove a UNIQUE constraint on a column for sqlite but I do not have the name to remove the constraint. How can I find the name of the UNIQUE constraint name to remove it. Below is the schema I see for the table I want to remove the constraint UNIQUE (datasource_name) sqlite> .schema datasources CREATE TABLE "datasources" ( created_on DATETIME NOT NULL, changed_on DATETIME NOT NULL, id INTEGER NOT NULL, datasource_name VARCHAR(255), is_featured BOOLEAN, is_hidden BOOLEAN,

「分布式技术专题」三种常见的数据库查询引擎执行模型

元气小坏坏 提交于 2021-02-18 20:46:44
注: 本文涉及到的相关资料图片摘自 CARNEGIE MELLON DATABASE GROUP 发表的 CMU SCS 15-721 (Spring 2019) :: Query Execution & Processing (点击可查看) 1. 迭代模型/火山模型(Iterator Model) 又称 Volcano Model 或者 Pipeline Model 。 该计算模型将关系代数中每一种操作抽象为一个 Operator,将整个 SQL 构建成一个 Operator 树,查询树自顶向下的调用next()接口,数据则自底向上的被拉取处理。 火山模型的这种处理方式也称为拉取执行模型(Pull Based)。 大多数关系型数据库都是使用迭代模型的,如 SQLite、MongoDB、Impala、DB2、SQLServer、Greenplum、PostgreSQL、Oracle、MySQL 等。 火山模型的优点在于:简单,每个 Operator 可以单独实现逻辑。 火山模型的缺点:查询树调用 next() 接口次数太多,并且一次只取一条数据,CPU 执行效率低;而 Joins, Subqueries, Order By 等操作经常会阻塞。 2. 物化模型(Materialization Model) 物化模型的处理方式是:每个 operator 一次处理所有的输入

Save Dataset to SQLite format file

梦想的初衷 提交于 2021-02-18 19:31:08
问题 I have a dataset with multiple tables. I can obviously do a Dataset.WriteToXML("Somefile.xml") What if I want to export the dataset to a SQLite formatted file. In other words I want to be able to write (i.e. serialize) the contents of the dataset to a SQLite file. Dataset.SerializeToSQLite("Sqliteformatted.bin") Similarly I want to be able to read the SQLite file into a Dataset. I would like to do this in c#. Thanks in advance to any pointers. Bob 回答1: SQLite is not a file format, it's a

How to handled SQLITE errors such as “has no column named” that are not raised as Exceptions?

寵の児 提交于 2021-02-18 18:17:09
问题 what is the best way to catch the "errors" from the SQLite DB in Python as they are not considered as exceptions in Python. The error output after I tried an INSERT OR IGNORE statement where a column did not exist in the DB is as follows ('table X has no column named Y,) The following statement is used to execute the query cursor.execute("INSERT...") THe approach I thought of, does not work as a rowcount is not returned when there is an error on the cursor/ query if cursor.rowcount != 1:

Dealing with Relative Paths with node.js

一笑奈何 提交于 2021-02-18 17:50:08
问题 I'm wanting to include a .db database file for use with sqlite3 in my node.js project. My problem arises when the module which opens the database connection is required by files in different directories. My project structure is like so: project/ |--lib/ | |--foo.js | `--bar.js |--db/ | `--database.db `--server.js My foo.js file contains opens the database like so: var sqlite3 = require('sqlite3'); var db = new sqlite3.Database('db/database.db'); module.exports = { foo: function() { db

sqlite - find recipes that can be made from a set of ingredients

若如初见. 提交于 2021-02-18 17:09:53
问题 Right now I am using sqlite within a ios application, and I want to be able to search for recipes that can be made from a list of ingredients (ie recipes such that are a subset of the provided ingredients) For example: Recipe 1: A B C Recipe 2: A B Recipe 3: C D Recipe 4: A Recipe 5: E Query for ingredients A B C returns recipes {1, 2, 4} Query for ingredients A B returns recipes {2, 4} Query for ingredients D returns {} Currently what I have set up is Table Items name text primary key Table

sqlite - find recipes that can be made from a set of ingredients

为君一笑 提交于 2021-02-18 17:07:33
问题 Right now I am using sqlite within a ios application, and I want to be able to search for recipes that can be made from a list of ingredients (ie recipes such that are a subset of the provided ingredients) For example: Recipe 1: A B C Recipe 2: A B Recipe 3: C D Recipe 4: A Recipe 5: E Query for ingredients A B C returns recipes {1, 2, 4} Query for ingredients A B returns recipes {2, 4} Query for ingredients D returns {} Currently what I have set up is Table Items name text primary key Table