打开 Firefox 文件“places.sqlite”使用 PowerShell 和 System.Data.SQLite

发布于 2024-11-03 10:21:29 字数 1946 浏览 1 评论 0原文

我想运行以下代码:

$dll = [System.Reflection.Assembly]::LoadWithPartialName("System.Data.SQLite")
# [System.Reflection.Assembly]::LoadFrom("C:\Program Files\System.Data.SQLite\bin\System.Data.SQLite.dll")

$ConnectionString = "Data Source=C:\Var\sqlite_ff4\places.sqlite"

$conn = New-Object System.Data.SQLite.SQLiteConnection
$conn.ConnectionString = $ConnectionString
$conn.Open()
$sql = "SELECT * from moz_bookmarks"
$cmd = New-Object System.Data.SQLite.SQLiteCommand($sql, $conn)

#    $cmd.CommandTimeout = $timeout

$ds = New-Object system.Data.DataSet
$da = New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds)

$conn.close()

$ds.tables[0]

在该行

$conn.Open()

我收到错误

Exception calling "Open" with "0" argument(s): "File opened that is not a database file
file is encrypted or is not a database"
At line:5 char:11
+ $conn.Open <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

The file places.sqlite is from Firefox 4.0。我正在使用 http://sourceforge.net/projects/sqlite-dotnet2/files/< /a>.

编辑:

以上适用于 Firefox 3.0 文件 places.sqlite。 Firefox 4.0 似乎有些不同。

看来不是密码问题,而是版本问题。感谢 这篇 StackOverflow 帖子,我发现我需要 SQLite 3.7。

我希望我能找到一些当前的 ADO 提供商。

sqlite-dotnet-x86-1006900.exe 来自 此处< /a> 不起作用

使用“0”参数调用“Open”时出现异常:“无法加载 DLL 'SQLite.Inte” rop.DLL': 找不到指定的模块。 (HRESULT 异常:0x8 007007E)"

这可能是一个调试版本。是否有任何没有 SQLite.Interop.DLL 的预构建版本?

I want to run the following code:

$dll = [System.Reflection.Assembly]::LoadWithPartialName("System.Data.SQLite")
# [System.Reflection.Assembly]::LoadFrom("C:\Program Files\System.Data.SQLite\bin\System.Data.SQLite.dll")

$ConnectionString = "Data Source=C:\Var\sqlite_ff4\places.sqlite"

$conn = New-Object System.Data.SQLite.SQLiteConnection
$conn.ConnectionString = $ConnectionString
$conn.Open()
$sql = "SELECT * from moz_bookmarks"
$cmd = New-Object System.Data.SQLite.SQLiteCommand($sql, $conn)

#    $cmd.CommandTimeout = $timeout

$ds = New-Object system.Data.DataSet
$da = New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds)

$conn.close()

$ds.tables[0]

At the line

$conn.Open()

I get the error

Exception calling "Open" with "0" argument(s): "File opened that is not a database file
file is encrypted or is not a database"
At line:5 char:11
+ $conn.Open <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

The file places.sqlite is from Firefox 4.0. I'm using http://sourceforge.net/projects/sqlite-dotnet2/files/.

EDIT:

The above works for the Firefox 3.0 file places.sqlite. Something seems to be different with Firefox 4.0.

It doesn't seem to be a password problem, but a version problem. Thanks to this Stack Overflow post I found, that I need SQLite 3.7.

I hope I find some current ADO provider.

sqlite-dotnet-x86-1006900.exe from here doesn't work

Exception calling "Open" with "0" argument(s): "Unable to load DLL 'SQLite.Inte
rop.DLL': The specified module could not be found. (Exception from HRESULT: 0x8
007007E)"

It is possibly a debug build. Are there any prebuild version without an SQLite.Interop.DLL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下的泡沫是彩色的 2024-11-10 10:21:29

最终解决了(通过不在 GAC 中安装的解决方法):

要打开 Firefox 4.0places.sqlite,您必须使用 sqlite 的 3.7 或更高版本。

我从 这里安装了 sqlite-dotnet-x86-1007000.exe ,但没有选中GAC 中的安装复选框。在GAC中安装仍然错误。

现在,以下PowerShell代码可以在places.sqlite的副本上正常工作(请记住,在被Firefox锁定时无法打开它):

# adapt these two lines to your loacal system
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\System.Data.SQLite\bin\System.Data.SQLite.dll") 
$ConnectionString = "Data Source=C:\Var\sqlite_ff4\places.sqlite"

$conn=new-object System.Data.SQLite.SQLiteConnection 
$conn.ConnectionString=$ConnectionString 
$conn.Open() 
$sql = "SELECT * from moz_bookmarks"
$cmd=new-object System.Data.SQLite.SQLiteCommand($sql,$conn)
$ds=New-Object system.Data.DataSet
$da=New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds) 
$conn.close()
$ds.tables[0]

由于sqlite-dotnet-x86-1006900.exe,它们从System.Data中吐出了SQLite.Interop.dll。 SQLite.dll,但在 GAC 中安装它时遇到问题。如果您选中“GAC 中的安装”复选框,您会得到一个
无法加载 DLL 'SQLite.Interop.DLL
错误。此错误有一个已关闭的票据,但我认为它不是固定的。票再次重新打开。在那里检查新的解决方法或解决方案。

Finally solved (by work around of not installing in GAC):

To open Firefox 4.0 places.sqlite you must use a version 3.7 or upper from sqlite.

I installed sqlite-dotnet-x86-1007000.exe from here, but did not check the install in GAC checkbox. Install in GAC is still faulty.

Now the following PowerShell Code works fine on a copy of places.sqlite (remember you can't open it while locked by Firefox):

# adapt these two lines to your loacal system
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\System.Data.SQLite\bin\System.Data.SQLite.dll") 
$ConnectionString = "Data Source=C:\Var\sqlite_ff4\places.sqlite"

$conn=new-object System.Data.SQLite.SQLiteConnection 
$conn.ConnectionString=$ConnectionString 
$conn.Open() 
$sql = "SELECT * from moz_bookmarks"
$cmd=new-object System.Data.SQLite.SQLiteCommand($sql,$conn)
$ds=New-Object system.Data.DataSet
$da=New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds) 
$conn.close()
$ds.tables[0]

Since sqlite-dotnet-x86-1006900.exe they spitted SQLite.Interop.dll from System.Data.SQLite.dll, but had problems with installing it in GAC. If you check the install in GAC checkbox, you get an
Unable to load DLL 'SQLite.Interop.DLL
error. There is a closed ticket for this error, but I think it is not fixed. The ticket is reopened again. check there for new work arounds or solutions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文