简体   繁体   English

Perl DBI 数据库密码

[英]Database Password with Perl DBI

So I am creating a file on a server with Perl DBI.所以我正在使用 Perl DBI 在服务器上创建一个文件。 This file is created with:这个文件是用以下方法创建的:

my $dbFile = DBI->connect("DBI:SQLite:dbname=folder/databaseName.db", "", "desiredPassword", optionArray);

My driver is obviously SQLite and the file extension is .db .我的驱动程序显然是 SQLite,文件扩展名是.db Later on I want to use this file in Visual Studio with the following connection string (everything will be on a local file so NO data stream to any databank):稍后我想在 Visual Studio 中使用此文件和以下连接字符串(所有内容都在本地文件中,因此没有数据流到任何数据库):

Data Source=myfile.sqlite;Password=desiredPassword;Version=3 

Basically all I do is to download the .db file from the server into a local SQLite file, but that works perfectly fine.基本上我所做的就是将.db文件从服务器下载到本地 SQLite 文件中,但这工作得很好。

My problem is that I have no idea how to set a password for the database I create with the connection string in the code example.我的问题是我不知道如何为我在代码示例中使用连接字符串创建的数据库设置密码。 I assumed that it should just be settable in the DBI connect function that creates the file.我认为它应该可以在创建文件的DBI连接函数中设置。 However this doesn't work at all.然而,这根本不起作用。 So how can I set a password for my .db file with Perl DBI?那么如何使用 Perl DBI 为我的.db文件设置密码?

Because there is no implementation of databank encryption in perl and apparently different libraries have their own implementation (there does not seem to be a standard for that) the encryption has to be done via the library which will later decrypt the password.因为在 perl 中没有实现数据库加密,而且显然不同的库有自己的实现(似乎没有标准),加密必须通过库完成,稍后将解密密码。 My solution was to write a script in Visual Studio which will acquire all data from a database (or just a database file) and stores it in a sql file which will then be encrypted with the desired password.我的解决方案是在 Visual Studio 中编写一个脚本,该脚本将从数据库(或只是一个数据库文件)中获取所有数据并将其存储在一个 sql 文件中,然后使用所需的密码对其进行加密。

So while there are some independet solutions for several libaries, there in no solution for perl DBI因此,虽然对于多个库有一些独立的解决方案,但没有针对 perl DBI 的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM