Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the function that supports sqlite to set password? #466

Open
vootooguru opened this issue Nov 29, 2023 · 7 comments
Open

How to use the function that supports sqlite to set password? #466

vootooguru opened this issue Nov 29, 2023 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@vootooguru
Copy link

你好,我看到代码中有给sqlite设置密码的功能,有点小bug会导致设置被覆盖,修改之后,经测试没有效果,请问下怎么才能给sqlite设置密码呢?

 if let Some(pragma_key_password) = self.pragmas.get("key") {
                write!(init, "PRAGMA key = {}; ", pragma_key_password).ok();
 }
@Issues-translate-bot Issues-translate-bot changed the title 支持sqlite设置密码的功能怎么用? How to use the function that supports sqlite to set password? Nov 29, 2023
@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Hello, I saw that there is a function to set a password for SQLite in the code. A small bug will cause the setting to be overwritten. After modification, it has no effect after testing. How can I set a password for SQLite?

 if let Some(pragma_key_password) = self.pragmas.get("key") {
                write!(init, "PRAGMA key = {}; ", pragma_key_password).ok();
 }

@zhuxiujia zhuxiujia added the help wanted Extra attention is needed label Nov 29, 2023
@rbatis rbatis deleted a comment from Issues-translate-bot Nov 29, 2023
@zhuxiujia
Copy link
Member

你好,我看到代码中有给sqlite设置密码的功能,有点小bug会导致设置被覆盖,修改之后,经测试没有效果,请问下怎么才能给sqlite设置密码呢?

 if let Some(pragma_key_password) = self.pragmas.get("key") {
                write!(init, "PRAGMA key = {}; ", pragma_key_password).ok();
 }
    use rbatis::{DefaultPool, RBatis};
    use rbdc_sqlite::{SqliteConnectOptions, SqliteDriver};

    let mut rb = RBatis::new();
    let mut opts = SqliteConnectOptions::default().pragma("key","password");
    opts.set_uri("sqlite://target/sqlite.db");
    rb.init_option::< SqliteDriver, SqliteConnectOptions, DefaultPool>(SqliteDriver{}, opts).unwrap();

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Hello, I saw that there is a function to set a password for SQLite in the code. A small bug will cause the setting to be overwritten. After modification, it has no effect after testing. How can I set a password for SQLite?

if let Some(pragma_key_password) = self.pragmas.get("key") {
write!(init, "PRAGMA key = {}; ", pragma_key_password).ok();
}
    use rbatis::{DefaultPool, RBatis};
    use rbdc_sqlite::{SqliteConnectOptions, SqliteDriver};

    let mut rb = RBatis::new();
    let mut opts = SqliteConnectOptions::default().pragma("key","password");
    opts.set_uri("sqlite://target/sqlite.db");
    rb.init_option::< SqliteDriver, SqliteConnectOptions, DefaultPool>(SqliteDriver{}, opts).unwrap();

@zhuxiujia
Copy link
Member

run cargo update to up to rbatis = "v4.5.5"

@vootooguru
Copy link
Author

run cargo update to up to rbatis = "v4.5.5"

OK,thx!

@vootooguru
Copy link
Author

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Hello, I saw that there is a function to set a password for SQLite in the code. A small bug will cause the setting to be overwritten. After modification, it has no effect after testing. How can I set a password for SQLite?

if let Some(pragma_key_password) = self.pragmas.get("key") {
write!(init, "PRAGMA key = {}; ", pragma_key_password).ok();
}
    use rbatis::{DefaultPool, RBatis};
    use rbdc_sqlite::{SqliteConnectOptions, SqliteDriver};

    let mut rb = RBatis::new();
    let mut opts = SqliteConnectOptions::default().pragma("key","password");
    opts.set_uri("sqlite://target/sqlite.db");
    rb.init_option::< SqliteDriver, SqliteConnectOptions, DefaultPool>(SqliteDriver{}, opts).unwrap();

按这种方式修改后,option的pragmas应该在某个地方被替换成了默认的值,传入的key参数在实际执行的时候就没有了,我的代连接代码是这样的:
image
在rbatis连接的代码中加入了日志查看
image
连接的时候输出是这样的:
image

我暂时还没找到在哪里被替换成默认值的

@vootooguru
Copy link
Author

我估计是这里被替换成默认值了,但在连接池中的创建关系还没理清楚
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants