問題タブ [isqlquery]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
58 参照

sql - SQL Oracle コマンド「右括弧がありません」

このテーブルを作成するたびに、右括弧がありませんと表示されます。誰かが私が間違っていることを確認してください。ありがとうございました

0 投票する
1 に答える
121 参照

python - Boolean を DataFrames sqlQuery str に連結する

決定木を構築するために気象データベースにクエリを実行しようとしています。その中には14個のインスタンスがあり、クエリしたい意図したサブセットに基づいて新しいデータフレームを作成しています-->

5 つのインスタンスを持つ新しいデータフレームが生成されます。

プログラムをより動的にするために、次のような解析済みヘッダーを使用してデータセットを反復処理しています

column_names[0] は Outlook と同じです。これは正常に動作していますが、私が抱えている問題は、ブール値である Windy に来るときです。私の質問は、ブール値を文字列に解析して df クエリを作成する方法です。現時点で私のコードは次のようになっています

しかし、私が得ているエラーは TypeError: cannot concatenate 'str' and 'bool' objects です。連結に関して多くのバリエーションを試しましたが、正しいフォーマットをまだ見つけていません。 .

0 投票する
1 に答える
109 参照

ios - How does sqlite select the index when querying records?

  1. Background 

    I am an iOS developer, and we use CoreData which uses sqlite database to store data in the disk in our project. Several days before one of our users said that his interface is not fluent in some case when using our app which version is 2.9.9. After some efforts we finally found that it is due to the bad efficiency when querying records from sqlite. But after updating to the latest version 3.0.6, the issue disappeared. 

  2. Analyze

    (1) when querying records from sqlite, the SQL query is

    'SELECT * FROM ZAPIOBJECT WHERE ZAPIOBJECTID = "xxx" AND Z_ENT == 34'

    In the version 2.9.9 of our app, the schema of table ‘ZAPIOBJECT’ of the sqlite shows

    'CREATE INDEX ZAPIOBJECT_Z_ENT_INDEX ON ZAPIOBJECT (Z_ENT);'

    'CREATE INDEX ZAPIOBJECT_ZAPIOBJECTID_INDEX ON ZAPIOBJECT (ZAPIOBJECTID);'

    and the query plan shows

    '0 0 0 SEARCH TABLE ZAPIOBJECT AS t0 USING INDEX ZAPIOBJECT_Z_ENT_INDEX (Z_ENT=?)’</p>

    which uses the less efficient index ‘Z_ENT’ (cost ~4s for 1 row).

    (2) In the version 3.0.6 of our app, the SQL query is the same:

    'SELECT * FROM ZAPIOBJECT WHERE ZAPIOBJECTID = "xxx" AND Z_ENT == 34'

    but the schema of table ‘ZAPIOBJECT’ of the sqlite shows:

    ‘CREATE INDEX ZAPIOBJECT_Z_ENT_INDEX ON ZAPIOBJECT (Z_ENT);’

    ‘CREATE INDEX Z_APIObject_apiObjectID ON ZAPIOBJECT (ZAPIOBJECTID COLLATE BINARY ASC);’</p>

    and the query plan shows

    ‘0 0 0 SEARCH TABLE ZAPIOBJECT AS t0 USING INDEX Z_APIObject_apiObjectID (ZAPIOBJECTID=?)’

    which uses the more efficient index ‘ZAPIOBJECTID’ (cost ~0.03s for 1 row).

    (3) the total number of records in the table 'ZAPIOBJECT' is about 130000, and the index ‘ZAPIOBJECTID’ which distinct count is more than 90000 is created by us, while the index ‘Z_ENT’ which distinct count is only 20 is created by CoreData.

    (4) the versions of the sqlites in the two versions of our app are the same 3.8.8.3.

  3. Questions

    (1) how sqlite select index when querying records? In the document Query Planning I learn that sqlite would select the best algorithms by itself, however in our case selecting the different index can lead to obvious efficiency.Does the difference between the creation of ‘ZAPIOBJECTID’ in two version of our app lead to the different index adopted by sqlite?

    (2) It seems that those users whose system version is lower than iOS 11 would have this issue, so how can we solve this problem for them? Can we set ‘ZAPIOBJECTID’ as the designated index with CoreData API?