1

ID列350268180138164200にかなり大きな値を持つ行があります。それを選択しようとすると

select * from my_table where id=350268180138164200

何も得られませんが、たとえば id=222 の行を挿入すると、問題なく選択できます。

select *, typeof(id) from my_table 

id のデータ型が整数であることを示しています。

更新:挿入コードを変更することで問題を解決しました。これは次のようになります。

conn = lite.connect('my.sqlite')

with conn:
cur = conn.cursor()


    cur.execute("INSERT INTO MY_TABLE (ID) "
                    "VALUES( :id)",
                    { 'id' : -here is smth of type = long- } )
    conn.commit()

今、私はそれを次のように変更しました(そして選択は機能しています):

conn = lite.connect('my.sqlite')

with conn:
cur = conn.cursor()


    cur.execute("INSERT INTO MY_TABLE (ID) "
                    "VALUES( CAST(:id AS INTERGER))",
                    { 'id' : -here is smth of type = long- } )
    conn.commit()

したがって、python sqlite モジュール (または sqlite lib 自体) が何らかのキャストを行っていたと思われますが、これは私の目標に沿ったものでした。それともわからない。

4

1 に答える 1

2

ここで動作します:

sqlite> create table t (id integer);
sqlite> insert into t values (350268180138164200);
sqlite> select * from t;
350268180138164200
sqlite> select * from t where id = 350268180138164200;
350268180138164200
sqlite> select *, typeof(id) from t where id = 350268180138164200;
350268180138164200|integer
于 2013-06-28T09:49:46.277 に答える