Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database Zeoslib无法从sqlite数据库读取大字段_Database_Sqlite_Delphi_Delphi Xe2_Zeos - Fatal编程技术网

Database Zeoslib无法从sqlite数据库读取大字段

Database Zeoslib无法从sqlite数据库读取大字段,database,sqlite,delphi,delphi-xe2,zeos,Database,Sqlite,Delphi,Delphi Xe2,Zeos,我正在尝试使用ZeosLib组件和DelphiXe2读取sqlite数据库。除了我试图读取存储的三个时间戳值(基本上都是17位数字)外,所有的工作都非常完美。我得到的不是正确的值,而是零。读取数据库数据的函数(注意注释行): 我已经尝试了我想到的一切,从简单地使用.AsLargeInt()getter获取值,到将其作为变量,然后转换为整数/Int64/字符串,等等。。在所有情况下,我都得到零作为返回值。我还尝试了ZeosLib的不同版本,特别是7.0.6-stable和7.1.1-rc版本。由于

我正在尝试使用ZeosLib组件和DelphiXe2读取sqlite数据库。除了我试图读取存储的三个时间戳值(基本上都是17位数字)外,所有的工作都非常完美。我得到的不是正确的值,而是零。读取数据库数据的函数(注意注释行):

我已经尝试了我想到的一切,从简单地使用
.AsLargeInt()
getter获取值,到将其作为
变量
,然后转换为
整数
/
Int64
/
字符串
,等等。。在所有情况下,我都得到零作为返回值。我还尝试了ZeosLib的不同版本,特别是
7.0.6-stable
7.1.1-rc
版本。由于与较新版本的Delphi不兼容,无法使用
6.6.6-stable
one进行编译

以下是我使用SQLite Manager(firefox插件)打开数据时的样子:

和表结构:

我尝试了另一种方法,通过使用
DISqlite3
组件读取数据,它们可以工作,但是它们是共享软件,如果可能的话,我宁愿使用免费软件


你知道是什么导致了这个奇怪的错误吗?

为了回答我自己的问题,我在他们的官方论坛上创建了这个帖子,并得到了以下回复:

Zeos是一个公共访问组件。我知道我们可以假设整数字段为Int64类型

实际上,我们使用BIGINT来假定TLongInt字段。RDBM最常用于哪些方面

这是一次公开讨论。Internaly SQLite为准备的语句接受两个整数绑定。制作此修补程序没有问题

因此,如果我们需要改变或不改变,其他人可以在这里发布。如果您有疑问,请选择7.2,而不是7.0或7.1。想想看:这是一个长期存在的代码。如果用户确实更新了这些组件,可能会带来很多麻烦


[]试试trunc(…AsDouble)。不完美,但可能有效。或者我们的开放源代码类,用于全速直接访问SQlite3-请参阅-Int64大数字没有问题。:)非常感谢。我现在就让SynDBSQLite3试一试。Trunc()没有做到这一点。请尝试将字段定义为BIGINT;请参阅此处的帖子:数据库是外部的,所以我无法编辑它-然而,SynDBSQLite似乎工作得完美无缺:)您有可用的事务方法。其余的听起来不错。另请参见独占模式以获得最佳速度。我们的博客上有一些文章,mORMot文档也很详尽。
procedure TCookieImporter.LoadCookies(const AChromeDatabase: String);
var
  zconn          : TZConnection;
  zquery         : TZReadOnlyQuery;
  creation_utc   : Int64;
  expires_utc    : Int64;
  last_access_utc: Int64;
  host_key       : String;
  name           : String;
  value          : String;
  path           : String;
  secure         : Integer;
  httponly       : Integer;
  has_expires    : Integer;
  persistent     : Integer;
  priority       : Integer;
  cookie         : TChromeCookie;
begin
  zconn := TZConnection.Create(nil);
  try
    zconn.Protocol := 'sqlite-3';
    zconn.Database := AChromeDatabase;
    zconn.Connect;
    if zconn.Connected then
    try
      zquery := TZReadOnlyQuery.Create(nil);
      try
        zquery.Connection := zconn;
        zquery.SQL.Text := 'SELECT * FROM cookies';
        zquery.Active := TRUE;
        while not zquery.Eof do
        begin
          // bug: following three lines - they all return zero
          creation_utc := zquery.FieldByName('creation_utc').AsLargeInt;
          expires_utc := zquery.FieldByName('expires_utc').AsLargeInt;
          last_access_utc := zquery.FieldByName('last_access_utc').AsLargeInt;

          // debug info for SO
          WriteLn(zquery.FieldDefs[0].Name); // = creation_utc
          WriteLn(zquery.FieldDefs[0].Size); // = 0
          WriteLn(zquery.FieldByName('creation_utc').AsString); // = 0
          WriteLn(VarToStr(zquery.FieldValues['creation_utc'])); // = 0
          dt := zquery.FieldDefs[0].DataType; // dt = ftInteger

          host_key := zquery.FieldByName('host_key').AsString;
          name := zquery.FieldByName('name').AsString;
          value := zquery.FieldByName('value').AsString;
          path := zquery.FieldByName('path').AsString;
          secure := zquery.FieldByName('secure').AsInteger;
          httponly := zquery.FieldByName('httponly').AsInteger;
          has_expires := zquery.FieldByName('has_expires').AsInteger;
          persistent := zquery.FieldByName('persistent').AsInteger;
          priority := zquery.FieldByName('priority').AsInteger;

          cookie := TChromeCookie.Create(creation_utc, host_key, name, value, path, expires_utc, secure, httponly, last_access_utc, has_expires, persistent, priority);
          FChromeCookies.Add(cookie);

          zquery.Next;
        end;
      finally
        zquery.Free;
      end;
    finally
      zconn.Disconnect;
    end;
  finally
    zconn.Free;
  end;
end;