var
conn: TFDConnection;
qry: TFDQuery;
begin
conn := TFDConnection.Create(nil);
try
conn.DriverName := 'SQLite';
conn.Params.Values['Database'] := 'C:\path\to\your\database.db3'; // 指定数据库文件路径
conn.Connected := True;
qry := TFDQuery.Create(nil);
try
qry.Connection := conn;
// 创建表的SQL语句
qry.SQL.Text := 'CREATE TABLE IF NOT EXISTS People (' +
'Id INTEGER PRIMARY KEY AUTOINCREMENT,' +
'FirstName VARCHAR(50),' +
'LastName VARCHAR(50),' +
'Age INTEGER)';
// 执行SQL语句创建表
qry.ExecSQL;
ShowMessage('数据库和表创建成功');
finally
qry.Free;
end;
finally
conn.Free;
end;
end;