X



トップページDB@2ch掲示板
1002コメント312KB
SQLite Part.10
■ このスレッドは過去ログ倉庫に格納されています
0379377
垢版 |
2014/06/18(水) 12:01:03.92ID:/pFl4NPD
>>378
1234という値を外したいと思い「NOT IN ('1234')」というのを付加したのですが
WHEREで外すということでしょうか。
0380NAME IS NULL
垢版 |
2014/06/18(水) 12:20:05.48ID:???
RANDOM() NOT IN ('1234')
だとRANDOM()の結果が'1234'以外は1が返るだけじゃないかな

SELECT sample_id FROM user_list WHERE sample_id NOT IN (1234) ORDER BY RANDOM() LIMIT 3;

こうならん?
0381NAME IS NULL
垢版 |
2014/06/18(水) 23:39:59.17ID:b5gx/YIo
すごく初心者で申し訳ありません。質問です
.txtに入っている|で区切ってある顧客情報をsqlite3を使ってテーブル作りたいです。import
filename table name をsqlite3.exeで実行して、テーブルを入れたデータベースをsqlitebrowser
でみてましたがなにもはいっていません。どうしたらよいでしょうか。。
。お願いします!!!
0382NAME IS NULL
垢版 |
2014/06/18(水) 23:58:31.98ID:???
>>381
質問する時は情報を正確に。
・txtには何が入っている?
・どんなテーブルに格納しようとしている?
・importを実行した時に出たメッセージは?
・sqlitebrowserとやらで出たメッセージは?
0383NAME IS NULL
垢版 |
2014/06/19(木) 10:21:48.77ID:???
sqlite3.exe で .import したんだったら、その場で select * from tablename
してみるといい
0384NAME IS NULL
垢版 |
2014/06/19(木) 12:50:27.04ID:???
sqliteってどのくらいの規模に耐えられますか?
0386NAME IS NULL
垢版 |
2014/06/19(木) 18:02:26.48ID:???
>>384
規模=DBサイズのことを言ってるならスペック最大値は128TiBまで。のLimits(>>1)参照
規模=クライアント数のことを言ってるならアクセス頻度とかを考慮してもあまり多い案件には向かない。
0387NAME IS NULL
垢版 |
2014/06/19(木) 20:31:18.65ID:???
DBサイズが多くなるとパフォーマンスって下がりますかね?
0388381
垢版 |
2014/06/19(木) 21:16:13.91ID:eiPp00xe
すいません 382さん、383さんありがとうございます。解決しました。
文字の規格の問題だったようです。ありがとうございました。
0389NAME IS NULL
垢版 |
2014/06/19(木) 23:41:54.02ID:???
>>387
サイズはまあ、10Gとか20Gとかのレベルだったら平気
(でも、あんまり肥大化するなら他の(組み込み系じゃない)RDBMS使った方が良い)

それよりも個々のデータサイズとかアクセス回数が重要な気がする
SQLiteの性質上、全てのデータを単一のファイルに保存しているわけなので、
時間のかかるアクセス(=でかいデータ)を頻繁に行うとロック待ちが多発して性能が出ない
同時アクセス数が1ならその限りではないけどね
0390NAME IS NULL
垢版 |
2014/06/20(金) 01:32:58.22ID:???
ファイル一個で管理出来る手軽さ をポイントにしたほうがいいね。
0391NAME IS NULL
垢版 |
2014/06/27(金) 09:38:40.24ID:93MY7apK
◎2chスレッド勢いランキングサイトリスト◎

★+ニュース板
・ 2NN (推奨サイト)
・ 2chTimes
★+ニュース板新着
・ 2NN新着
・ Headline BBY
・ unker Headline
★+ニュース板その他
・ Desktop2ch
・ 記者別一覧
★全板
・ 全板縦断勢いランキング (推奨サイト)
・ スレッドランキング総合ランキング
・ ログ速
★全板実況込み
・ 2勢 (推奨サイト)
・ READ2CH
・ i-ikioi

※ 要タイトル検索
※ 2chブラウザ併用推奨
0392マッチ棒
垢版 |
2014/06/30(月) 11:41:19.65ID:???
こんばんはお世話になります
mySQLとPHPで構築したデータを、SQLiteに移植したいと考えています。
mySQLのViewという機能は、どのように実現したらよいでしょうけ?
0393NAME IS NULL
垢版 |
2014/06/30(月) 12:31:16.83ID:???
SQLiteもVIEWあるべ?
0394381
垢版 |
2014/06/30(月) 23:02:20.24ID:ixE6Je2A
初心者です。もしかしたらpythonの質問かもしれません。スレチだったらごめんなさい。
いまpython2.7からsqlite3で日本語のデータを含むテーブルを作りました。
これをpython上でpandas使ってみてみると文字化けすることなく見ることは出来ました。
しかしそのテーブルからstageという名のカラムに良好と書いてあるデータを取り出し
viewをつくろうと思い
cur.execute('create view viewname as select * from tablename where stage=良好)
としたのですが
OperationalError: near "繧キ繝ォ繝舌�": syntax error
とでてきて良好が文字化けしてしまいます
どうしたらよいでしょうか?おねがいします!!
0395NAME IS NULL
垢版 |
2014/07/01(火) 00:07:11.10ID:???
>>392
>mySQLのViewという機能
まずSQLを勉強してからMySQLとかSQLiteを触った方が良いよ。

>>394
pythonの質問なのでスレ違い。
0396NAME IS NULL
垢版 |
2014/07/01(火) 09:13:36.84ID:mnQrmKyM
UTF8をSJISで読んでる典型だな
0397NAME IS NULL
垢版 |
2014/07/01(火) 09:15:18.90ID:mnQrmKyM
だいたい、'良好' たろ
0398NAME IS NULL
垢版 |
2014/07/01(火) 16:22:24.42ID:???
文字化けを復元すると、「シルバ」、、、シルバーとかか
0399NAME IS NULL
垢版 |
2014/07/01(火) 21:09:32.50ID:???
文字化けを解読するクセはやめなさいw
0400NAME IS NULL
垢版 |
2014/08/17(日) 00:46:15.35ID:???
3.8.6
http://www.sqlite.org/releaselog/3_8_6.html

・Added support for hexadecimal integer literals in the SQL parser. (Ex: 0x123abc)
・Enhanced the PRAGMA integrity_check command to detect UNIQUE and NOT NULL constraint violations.
・Increase the maximum value of SQLITE_MAX_ATTACHED from 62 to 125.
・Increase the timeout in WAL mode before issuing an SQLITE_PROTOCOL error from 1 second to 10 seconds.
・Added the likely(X) SQL function.
・The unicode61 tokenizer is now included in FTS4 by default.
・Trigger automatic reprepares on all prepared statements when ANALYZE is run.
・Added a new loadable extension source code file to the source tree: fileio.c
・Add extension functions readfile(X) and writefile(X,Y) (using code copy/pasted from fileio.c in the previous bullet) to the command-line shell.
・Added the .fullschema dot-command to the command-line shell.
0401NAME IS NULL
垢版 |
2014/08/19(火) 03:50:20.94ID:???
何故か実装されてなかった16進数リテラルが実装されたか。
あとは排他的論理和演算子が何故実装されてないのかが謎
0402NAME IS NULL
垢版 |
2014/09/21(日) 00:43:04.92ID:I6B1K8ho
MySQLとか設計めんどくさいからSQLiteで済ましてしまう
0403NAME IS NULL
垢版 |
2014/09/21(日) 01:29:22.93ID:???
ちゃちゃっとDBならSQLiteだわな
いちいちpgsqlにしようとは思わない
0404NAME IS NULL
垢版 |
2014/09/21(日) 01:46:04.34ID:???
排他処理を自分でしないとだからめんどっちい・・
0405NAME IS NULL
垢版 |
2014/09/21(日) 01:56:15.89ID:???
え、排他処理は自動でされるぞ・・?
0406NAME IS NULL
垢版 |
2014/09/21(日) 09:51:39.17ID:???
共有フォルダとかだとぶつかる
0407NAME IS NULL
垢版 |
2014/09/21(日) 13:05:14.66ID:???
だからちゃちゃっとですよ。
マルチプロセスとかマルチスレッドとかなると
いろいろ考えなければならんからね
いちお 大丈夫だけどね やっぱねw
0408NAME IS NULL
垢版 |
2014/09/21(日) 15:17:01.56ID:???
マルチスレッドで衝突する「排他処理」とは一体なにを「排他」しているのか…
0409NAME IS NULL
垢版 |
2014/09/21(日) 17:10:18.53ID:???
>>406
今時flockも無いようなファイルシステムを共有するなよ

>>408
グローバル変数とか…?
0410NAME IS NULL
垢版 |
2014/09/21(日) 17:16:51.62ID:???
>>409
しょうがねえだろ、WindowsCEを現役で使ってんの
0412NAME IS NULL
垢版 |
2014/09/22(月) 22:53:39.82ID:???
"自分で作った排他処理"ほど信用ならないものはない
0413NAME IS NULL
垢版 |
2014/09/23(火) 00:21:29.49ID:???
排他処理にならないように使うのだ
0414NAME IS NULL
垢版 |
2014/10/18(土) 03:57:47.71ID:???
SQLite Release 3.8.7 On 2014-10-17 (3.8.7)
http://www.sqlite.org/releaselog/3_8_7.html

Performance Enhancements:
Many micro-optimizations result in 20.3% more work for the same number of CPU cycles relative to the previous release. The cumulative performance increase since version 3.8.0 is 61%.
(Measured using cachegrind on the speedtest1.c workload on Ubuntu 13.10 x64 with gcc 4.8.1 and -Os. Your performance may vary.)
The sorter can use auxiliary helper threads to increase real-time response. This feature is off by default and may be enabled using the PRAGMA threads command or the SQLITE_DEFAULT_WORKER_THREADS compile-time option.
Enhance the skip-scan optimization so that it is able to skip index terms that occur in the middle of the index, not just as the left-hand side of the index.
Improved optimization of CAST operators.
Various improvements in how the query planner uses sqlite_stat4 information to estimate plan costs.

New Features:
Added new interfaces with 64-bit length parameters: sqlite3_malloc64(), sqlite3_realloc64(), sqlite3_bind_blob64(), sqlite3_result_blob64(), sqlite3_bind_text64(), and sqlite3_result_text64().
Added the new interface sqlite3_msize() that returns the size of a memory allocation obtained from sqlite3_malloc64() and its variants.
Added the SQLITE_LIMIT_WORKER_THREADS option to sqlite3_limit() and PRAGMA threads command for configuring the number of available worker threads.
The spellfix1 extension allows the application to optionally specify the rowid for each INSERT.
Added the User Authentication extension.

Bug Fixes:
Fix a bug in the partial index implementation that might result in an incorrect answer if a partial index is used in a subquery or in a view. Ticket 98d973b8f5.
Fix a query planner bug that might cause a table to be scanned in the wrong direction (thus reversing the order of output) when a DESC index is used to implement the ORDER BY clause on a query that has an identical GROUP BY clause. Ticket ba7cbfaedc7e6.
Fix a bug in sqlite3_trace() that was causing it to sometimes fail to print an SQL statement if that statement needed to be re-prepared. Ticket 11d5aa455e0d98f3c1e6a08
Fix a faulty assert() statement. Ticket 369d57fb8e5ccdff06f1
0415NAME IS NULL
垢版 |
2014/10/19(日) 18:34:23.11ID:???
ユーザー認証拡張が興味深い
0416NAME IS NULL
垢版 |
2014/10/20(月) 17:14:47.83ID:???
小さな改善をコツコツ積み重ねたら20.3%高速化したってこと? すごいね。
0417NAME IS NULL
垢版 |
2014/10/20(月) 22:24:19.30ID:???
開発チームはいい仕事するね
でもオプティマイザの改善は使う側がへボイと逆に100倍遅くなるんこともあるんだ
もちろん俺のことさ
その改善バージョンのリリースノートにもご丁寧に書いてあったよ。インデックス張れってね
ハハハ
0419NAME IS NULL
垢版 |
2014/11/06(木) 02:57:56.17ID:???
SQLite Release 3.8.7.1 On 2014-10-30 (3.8.7.1)

In PRAGMA journal_mode=TRUNCATE mode, call fsync() immediately after truncating the journal file to ensure that the transaction is durable across a power loss.
Fix an assertion fault that can occur when updating the NULL value of a field at the end of a table that was added using ALTER TABLE ADD COLUMN.
Do not attempt to use the strchrnul() function from the standard C library unless the HAVE_STRCHRNULL compile-time option is set.
Fix a couple of problems associated with running an UPDATE or DELETE on a VIEW with a rowid in the WHERE clause.
0420NAME IS NULL
垢版 |
2014/11/19(水) 22:18:26.92ID:+solJAhq
SQLite Release 3.8.7.2 On 2014-11-19 (3.8.7.2)

・Enhance the ROLLBACK command so that pending queries are allowed to continue as long as the schema is unchanged.
 Formerly, a ROLLBACK would cause all pending queries to fail with an SQLITE_ABORT or SQLITE_ABORT_ROLLBACK error.
 That error is still returned if the ROLLBACK modifies the schema.
・Bug fix: Make sure that NULL results from OP_Column are fully and completely NULL and do not have the MEM_Ephem bit set. Ticket 094d39a4c95ee4.
・Bug fix: The %c format in sqlite3_mprintf() is able to handle precisions greater than 70.
・Bug fix: Do not automatically remove the DISTINCT keyword from a SELECT that forms the right-hand side of an IN operator since it is necessary if the SELECT also contains a LIMIT. Ticket db87229497.
0421NAME IS NULL
垢版 |
2014/12/04(木) 12:10:10.16ID:???
Accessしか知らない無知で申し訳ない
このDBMSは、Accessのようにあらかじめクエリを登録しておき
後からそのクエリを呼び出す仕組みはないと理解してよいのかな?
何らかの言語から都度クエリ文字列をexecuteするしかない?
0423NAME IS NULL
垢版 |
2014/12/04(木) 15:19:11.36ID:???
>>422
早速ありがとう
勉強してみます
0424NAME IS NULL
垢版 |
2014/12/06(土) 23:04:14.40ID:LOwRbxtB
SQLiteでのレコードの削除について質問させて下さい。

dateDataとflagというカラムが有り、
dateDataには201412061212といった値が入り、
flagには0か1の値が入ります。

flagが0でdateDataが最小値のレコードを1行だけ削除したい場合、
記述はどの様になりますでしょうか?

自分なりに調べて以下を記述したらエラーになりました。
delete from テーブル名 where flag = 0 order by dateData limit 1
どうぞ宜しくお願いします。
0426NAME IS NULL
垢版 |
2014/12/07(日) 00:03:15.50ID:???
へぇー
これエラーになるのか
面白いな
0427NAME IS NULL
垢版 |
2014/12/07(日) 00:38:28.95ID:???
SQLiteSpy 1.9.8 win32 でちゃちゃっと

[1] create table testtable(dateData int, flag int)

[2] insert into testtable (dateData, flag) values
(20141201120007, 0),
(20141201120003, 1),
(20141201120002, 1),
(20141201120007, 0),
(20141201120008, 0)

[3] select dateData, flag from testtable
dateData flag
20141201120007 0
20141201120003 1
20141201120002 1
20141201120007 0
20141201120008 0

[4] delete from testTable where flag = 0 order by dateData limit 1

[5] select dateData, flag from testtable
dateData flag
20141201120003 1
20141201120002 1
20141201120007 0
20141201120008 0
0428424
垢版 |
2014/12/07(日) 00:48:58.26ID:JECAD2Ur
すみません。環境書き忘れてました。

Android SDKで使用してます。
>>427さんの記述をコピペして実行しても
near "order": syntax error
となってしまいます。
0429NAME IS NULL
垢版 |
2014/12/07(日) 00:54:05.47ID:???
http://www.sqlite.org/lang_delete.html

>Optional LIMIT and ORDER BY clauses
>
>If SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option,
>then the syntax of the DELETE statement is extended by the addition of optional
>ORDER BY and LIMIT clauses:

ご使用になっている SQLite3 は SQLITE_ENABLE_UPDATE_DELETE_LIMIT オプションを付けて
コンパイルされたものではないのでしょう。
0430NAME IS NULL
垢版 |
2014/12/07(日) 10:43:16.83ID:???
まあ最小のものからランダムに1件消すなんて普通はやらんしな。
一意になるカラム無いならサロゲートキーつけては
0431424
垢版 |
2014/12/07(日) 11:43:36.15ID:JECAD2Ur
>>429様 >>430
ありがとうございます。

もう少し勉強して他の方法を探します。
0432NAME IS NULL
垢版 |
2014/12/07(日) 11:44:36.21ID:???
行と行の比較をするんだから、相関サブクエリ使うところじゃね?
0433NAME IS NULL
垢版 |
2014/12/07(日) 12:09:28.77ID:???
まあ1件しか無いのなら、min()で1件ひけば済むことではあるな
0434424
垢版 |
2014/12/07(日) 22:25:21.00ID:???
delete from テーブル名 where flag= 0 and dateData = (select min(dateData) from テーブル名 where flag= 0
で出来ました。
レスくれた方々ありがとうございました。
0435NAME IS NULL
垢版 |
2014/12/10(水) 23:35:36.34ID:???
SQLite Release 3.8.7.4 On 2014-12-09 (3.8.7.4)

Bug fix: Add in a mutex that was omitted from the previous release.
0436
垢版 |
2014/12/25(木) 19:45:05.19ID:???
/:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ヽ
    /:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://ヽ:::::::::::::::|
    l:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// ヽ::::::::::::::l
    l:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::/:::「'ヽ::::::::::://   ヽ:::::::::::|
    |::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ノl:::ノ l:::::::/      ヽ::::::::|
   ノ:::::::::::::::::::::::::::::::::::::::::::::::::::::/ ゙゙  ノ:::/ ,,;;;;;;,,    ,,,,ヽ:::::l
   ):::::::::::::::::::::::::::::::::::::::::::::::/    ノ/ __,'''i: ('''__):::l  
  )::::::::::::::::::::::::::::::::::::::::::::::::::/         ̄ ̄ン:. :「 ̄`ヾ   
 1:::::::::::::::::::::::「 `┤l:::::::::::::::::l          ̄   ,  ヽ ̄ l   
  `l:::::::::::::::::::::ヽ  :l li:::::::::::::/        ヽ  /´   `l  |
  ヽ::::::::::::::::::::::\_」 lヽ::::/         .l  !:-●,__ ノ  /      
  ノ:::::::::::::::::::::::::::ノ | l `゙゙           i ,,;;;;;;;;;;;;;;;;;;;;,  /ヽ       
,/ ヽ::::::::::::::::::::::(  l l::::::::..         /.:''/´ ̄_ソ  /  `ヽ
     ヽ:::::::::::::::ヽ | l:::::::::::...      /::// ̄ ̄_ソ  /    \   ヴッ!!
        ヽ:::::::\| l::::::::::::::::...    / :::.ゝ` ̄ ̄/ /       ヽ
           ヽ:::l l:::::::::::::::::::..      ̄ ̄;;'' /         ヽ
              l l;;;;;;:::::::::::::::.....;;;;............;;;;;;''ノ            l
              l l '''''''''''''''''''''''''''''''''''''' ̄l |             |

http://www.youtube.com/watch?v=z2qK2lhk9O0
0437NAME IS NULL
垢版 |
2015/01/16(金) 10:48:39.56ID:???
プログラミング歴は、10年以上になりますが
DBに関しては1年強レベルです。
で、質問なんですがSQLightを主に使っているんですが
命令文での、orとand文は、左結合ですか?
あと試した事は無いですがorとand文辺りは
カッコでくくっても認識してくれるんでしょうか?
どなたかご教示願います。
0438NAME IS NULL
垢版 |
2015/01/16(金) 16:28:43.73ID:???
10年以上もプログラミング歴がある割に
それくらい聞くより調べるほうが簡単で早くて正確だとわからないなんて……
0439NAME IS NULL
垢版 |
2015/01/16(金) 17:03:59.81ID:???
ネットがなかった頃からやってるんじゃね
本屋に買いに行って調べるより電話で聞く方が早いと思ってるんだろう
0440NAME IS NULL
垢版 |
2015/01/16(金) 17:09:53.39ID:???
とりあえず使ってるDBの名前を正しく覚えよう
0441NAME IS NULL
垢版 |
2015/01/16(金) 19:53:53.11ID:???
こんな奴にプログラマとかSEとかIT技術者とかなんとかエンジニアとか名乗られたくないな。
存在が迷惑死、業界から消えてくれ。
0442NAME IS NULL
垢版 |
2015/01/17(土) 07:50:19.49ID:???
SQLite Release 3.8.8

http://www.sqlite.org/releaselog/3_8_8.html

・Added the PRAGMA data_version command that can be used to determine if a database file has been modified by another process.
・Added the SQLITE_CHECKPOINT_TRUNCATE option to the sqlite3_wal_checkpoint_v2() interface,
 with corresponding enhancements to PRAGMA wal_checkpoint.
・Added the sqlite3_stmt_scanstatus() interface, available only when compiled with SQLITE_ENABLE_STMT_SCANSTATUS.
・The sqlite3_table_column_metadata() is enhanced to work correctly on WITHOUT ROWID tables
 and to check for the existence of a a table if the column name parameter is NULL.
 The interface is now also included in the build by default, without requiring the SQLITE_ENABLE_COLUMN_METADATA compile-time option.
・Added the SQLITE_ENABLE_API_ARMOR compile-time option.
・Added the SQLITE_REVERSE_UNORDERED_SELECTS compile-time option.
・Added the SQLITE_SORTER_PMASZ compile-time option and SQLITE_CONFIG_PMASZ start-time option.
・Added the SQLITE_CONFIG_PCACHE_HDRSZ option to sqlite3_config() which makes it easier for applications
 to determine the appropriate amount of memory for use with SQLITE_CONFIG_PAGECACHE.
・The number of rows in a VALUES clause is no longer limited by SQLITE_LIMIT_COMPOUND_SELECT.
・Added the eval.c loadable extension that implements an eval() SQL function that will recursively evaluate SQL.
0443NAME IS NULL
垢版 |
2015/01/21(水) 07:42:58.84ID:???
SQLite Release 3.8.8.1

http://www.sqlite.org/releaselog/3_8_8_1.html

・Fix a bug in the sorting logic, present since version 3.8.4, that can cause output to appear in the wrong order on queries
that contains an ORDER BY clause, a LIMIT clause, and that have approximately 60 or more columns in the result set.
Ticket f97c4637102a3ae72b79.
0444NAME IS NULL
垢版 |
2015/01/21(水) 21:26:58.85ID:???
バージョンアップが激しすぎてついていけない、、、
0445NAME IS NULL
垢版 |
2015/03/01(日) 00:37:15.47ID:sjX82R5K
>>440
神戸市の東、芦屋西宮の知的障害者施設で未成年利用者に性的な行為をして淫行条例で逮捕された三田谷学園元職員の堂垣直人(西宮市老松町)は、結局どういう罪になったの?
被害者家族のケアを芦屋市役所と兵庫県警はちゃんとやったのか?
差別や虐待は環境を選べない子供には関係ない。

http://www.youtube.com/watch?v=JxMzW3ZlV4g&;sns=em
0446NAME IS NULL
垢版 |
2015/04/12(日) 02:47:56.57ID:???
.NET用は32ビットと64ビットのバイナリをまとめて欲しいなぁ・・・
0447NAME IS NULL
垢版 |
2015/05/09(土) 17:01:37.72ID:ZgDS20Jy
SQLite Release 3.8.10 On 2015-05-07

Added the sqldiff.exe utility program for computing the differences between two SQLite database files.
Added the y format string to the matchinfo() function of FTS3.
Performance improvements for ORDER BY, VACUUM, CREATE INDEX, PRAGMA integrity_check, and PRAGMA quick_check.
Fix many obscure problems discovered while SQL fuzzing.
Identify all methods for important objects in the interface documentation. (example)
Made the American Fuzzy Lop fuzzer a standard part of SQLite's testing strategy.
Add the ".binary" and ".limits" commands to the command-line shell.
Make the "dbstat" virtual table part of standard builds when compiled with the SQLITE_ENABLE_DBSTAT_VTAB option.
0448NAME IS NULL
垢版 |
2015/05/25(月) 10:34:24.59ID:aYoHQFUg
環境:VC#2013 + System.Data.Sqlite(1.0.96.0)

既存のテーブルのカラムの内容を参照して、別のカラムに計算結果を格納する、と言う処理を行おうとしています。
計算結果を格納するカラムを後から追加した都合で、追加前のデータも参照、更新対象になります。
 以下のようなプログラムを組んだのですが、計算結果がrow["Dest"]に格納されているのにもかかわらず、
ad.Update()の結果が0、例外も発生しないという状態になっています。
 どこか手順等に誤りはありますでしょうか?

string strCommand = "SELECT * FROM ResultTable";
DataTable data = new DataTable();
string tmp = ""; int Calc;
using(conn = new SQLiteConnection(ConnectionString))
{
  conn.Open();
  using(SQLiteTransaction tr = conn.BeginTransaction())
  {
    using(SQLiteDataAdapter ad = new SQLiteDataAdapter(strGetDat, conn)){
      ad.Fill(data);
      SQLiteCommandBuilder bl = new SQLiteCommandBuilder(ad);
      ad.UpdateCommand = bl.GetUpdateCommand(true);
      ad.UpdateCommand.Transaction = tr;
      foreach(DataRow row in data.Rows){
        tmp = (string)row["Source"];
        // ここで計算する
        row["Dest"] = Calc;
      }
      data.AcceptChanges();
      int i =ad.Update(data);
      Debug.Print(i.ToString());
    }
  conn.Close();
  }
}
0449NAME IS NULL
垢版 |
2015/05/25(月) 11:31:55.32ID:???
トランザクションのブロックの中でクローズしてるからアボート扱いになってない?
ってそれ以前にUpdateが0返してんのか。
こっちで追試するには情報が足りないな、自分で埋めてもいけどめんどい。
0450NAME IS NULL
垢版 |
2015/06/28(日) 20:01:32.29ID:???
アンドロイドのSQLiteで6000件のデータ取るのに3秒かかるのって仕方ないですか
SQLかなんかおかしいですか
0451NAME IS NULL
垢版 |
2015/06/28(日) 20:30:20.20ID:???
クエリがわからなくちゃ回答のしようが無い
0452NAME IS NULL
垢版 |
2015/06/28(日) 20:57:16.44ID:???
あるテーブルの全データ取得のクエリならどうですか
1テーブルはLONG5個INT5個程度の小さいものです
3秒はかかりすぎな気がしますが
0453NAME IS NULL
垢版 |
2015/06/29(月) 22:28:26.88ID:???
実際に再現する、最小限のサンプル出したほうが早いと思うの
0454NAME IS NULL
垢版 |
2015/06/29(月) 23:21:42.08ID:???
6,000件のレンダリングに 3秒かかってるってオチじゃないよな?
0455NAME IS NULL
垢版 |
2015/06/30(火) 01:23:41.88ID:???
Rails あるあるだな。
0457NAME IS NULL
垢版 |
2015/07/05(日) 20:12:39.66ID:TKPBzH/E
SQLiteはそれ自身はセキュアじゃないし更新処理に弱いって聞いたけど実際のところどうなん?
0458NAME IS NULL
垢版 |
2015/07/06(月) 12:17:29.13ID:???
弱い を論理的にどうぞ
0459NAME IS NULL
垢版 |
2015/07/07(火) 08:33:31.65ID:???
SQLiteの欠点なんてネットにいくらでも情報が出てるだろ
少しは調べろっていう
0460NAME IS NULL
垢版 |
2015/07/29(水) 17:04:24.74ID:???
sqliteって正規表現検索が無いんだな。
0461NAME IS NULL
垢版 |
2015/07/30(木) 20:41:57.68ID:???
SQLite Release 3.8.11.1 On 2015-07-29
0462NAME IS NULL
垢版 |
2015/08/01(土) 01:05:44.56ID:???
>>460
正規表現使えるように改造すると良いよ。
0463NAME IS NULL
垢版 |
2015/08/06(木) 23:39:03.91ID:???
>>460
公式のextentionのregexp.cを組み込めば対応できるけど、標準のsqlite.dllでは出来ない。
あと、regexp.cでも、一致確認はできるけど置換が出来ないのが残念
0464NAME IS NULL
垢版 |
2015/08/07(金) 14:04:24.44ID:l/2WsGXW
データベース自体は単純な命令にのみ限定して
速度を上げるべき。データベースの出力結果を
phpやpythonの正規表現で処理すれば良いだけ。
0465NAME IS NULL
垢版 |
2015/08/13(木) 23:56:54.38ID:???
IN句に指定できるワード数は
Oracleは1000個、PostgreSQLは2000個、MySQLは上限なしとか決まっているようですが
SQLiteには制限ありますか
0466NAME IS NULL
垢版 |
2015/08/15(土) 22:45:27.21ID:???
>>465
100万ワードのin句を持つSQLをプログラム生成して試した。
select id from testtable where id in (1,2,3,....,1000000)
エラーにはならなかったよ。
0468NAME IS NULL
垢版 |
2015/08/16(日) 08:11:40.70ID:???
>>467

(1) テーブル作成
create table testtable(
id integer not null default 0,
xname text not null default '',
constraint pk_testtable primary key (id)
)

(2) データ2件投入
insert into testtable(id, xname) values(1001, 'hello')
insert into testtable(id, xname) values(1002, 'world')

(3) SQL 生成 & 実行
select id, xname from testtable where id in (1,2,...,N)

生成した SQL を sqlite3_exec で実行させて戻ってくるまでの時間

N=10000 285.892ms
N=100000 3960.603ms
N=1000000 43520.460ms

sqlite3 version 3.8.3.1
OS=Windows7 pro
CPU=Ivy Bridge 3770無印
0469NAME IS NULL
垢版 |
2015/08/16(日) 17:09:06.83ID:???
>>468
一箇所訂正

× 生成した SQL を sqlite3_exec で実行させて戻ってくるまでの時間
○ 生成した SQL を sqlite3_prepare_v2 で実行させて戻ってくるまでの時間
0470NAME IS NULL
垢版 |
2015/08/16(日) 18:14:20.35ID:???
速度の話が出ているので横から失礼します
Excelに接続出来る事を知りいろいろ調べているのですがリアルタイムに読み書きする時の速度はどんな感じでしょうか?
0471NAME IS NULL
垢版 |
2015/08/16(日) 21:01:55.98ID:???
そんなもんテーブル構造にもアクセス方法にもデータ量にもよりけりだから、自分で測った方が早いと思う。
0472NAME IS NULL
垢版 |
2015/08/17(月) 00:05:25.74ID:???
ん?
prepareではクエリの解釈だけで実行はされなかったと思うが
0473NAME IS NULL
垢版 |
2015/08/17(月) 16:29:35.95ID:???
>>468
エラーにはならないのは事実みたいね。
ほんとうの実測値が知りたいけど、後は各自がやるってことで。
0474NAME IS NULL
垢版 |
2015/08/19(水) 03:06:27.50ID:???
468 ですが、
Visual studio の IDE の中でテストプログラムを走らせると in 句 100 万件
のときにすごく時間がかかったのですが、cmd.exe から普通に起動してテスト
すると、1秒もかからなかったです。大変申し訳ありません。

ソース
http://www.rupan.net/uploader/download/1439920727.zip
dlpass:sqlite3

結果
SQLite3 version 3.8.11.1

#open: 1 ms

N=10000
#prepare: 8 ms
#step 1st: 6 ms
#step: 0 ms
#step: 1 ms
#finalize: 0 ms

N=100000
#prepare: 39 ms
#step 1st: 25 ms
#step: 0 ms
#step: 7 ms
#finalize: 0 ms

N=1000000
#prepare: 544 ms
#step 1st: 632 ms
#step: 0 ms
#step: 1 ms
#finalize: 56 ms

#close: 0 ms
0475NAME IS NULL
垢版 |
2015/08/30(日) 07:03:03.87ID:???
例えば2chのような巨大掲示板を運営するとして
ログにSQLite使うとします
普通は全体でDBを1つ用意するだけだと思いますが
DBってのは肥大するとSELECTも遅くなると思うので
お手軽SQLiteに限っては1スレッド1DBみたいなのでもいいんじゃないかと思ってるのですが
どうでしょう?やっぱおかしいですかね?
0476NAME IS NULL
垢版 |
2015/08/30(日) 08:31:17.57ID:???
>>475
基本的におかしい
サーバーはクライアントからのリクエストを見て
・url から該当のスレのデータベースを取得
・そのデータベースを開く
の操作が必要になる
もちろんレスのキャッシュや接続プールとかで高速化を図ればいいんだけど、なにか独自の技術でもない限りデータベース側に任せた方がいい
ビックデータ流行の時代なので巨大データに対する技術は色々開発されてる
0478NAME IS NULL
垢版 |
2015/08/31(月) 11:58:52.90ID:???
こんな感じでフォームのテキストボックスにログ流して表示しているのですが
このログをDBに入れるにはどうinsert文を書けばいいでしょうか?

String tickString = String.Format("{0},{1:HH:mm:ss},{2},{3}\r\n",
args.Instrument, args.Tick.DateTime, args.Tick.Price, args.Tick.Volume);

textBoxLog.Text = tickString + textBoxLog.Text;
}
■ このスレッドは過去ログ倉庫に格納されています

ニューススポーツなんでも実況