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

cli: Add cardano-wallet --database option #374

Closed
wants to merge 2 commits into from

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jun 6, 2019

Issue number #154
This PR is based on the branch of #373

Overview

  • Changes the DBLayer to use SQLite.
  • Without a given filename, it just uses the in-memory database.

rvl added 2 commits June 6, 2019 16:08
embedFile wasn't working for me in ghci.

  lib/cli/src/Cardano/CLI.hs:275:27: error:
      • Exception when trying to run compile-time code:
          ../../cardano-wallet.cabal: openBinaryFile: does not exist (No such file or directory)
        Code: embedFile "../../cardano-wallet.cabal"
      • In the untyped splice: $(embedFile "../../cardano-wallet.cabal")
      |
  275 |     let cabal = B8.unpack $(embedFile "../../cardano-wallet.cabal")
      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

There is another easier way to get the program version (assuming all
cabal files have the same version).
Changes the DBLayer to use SQLite. Without a given filename, it just
uses the in-memory database.
@rvl rvl self-assigned this Jun 6, 2019
@jonathanknowles jonathanknowles self-requested a review June 6, 2019 06:42
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a given filename, it just uses the in-memory database.

Just to confirm that my understanding is correct, is this in-memory database supposed to be in-memory-SQLite?

I found the following snippet:

createSqliteBackend :: Maybe FilePath -> LogFunc -> IO SqlBackend
createSqliteBackend fp logFunc = do
    conn <- Sqlite.open (sqliteConnStr fp)
    enableForeignKeys conn
    wrapConnection conn logFunc

sqliteConnStr :: Maybe FilePath -> Text
sqliteConnStr = maybe ":memory:" T.pack  

With this change, is there any way to specify the MVar database on startup? (Not sure if we want to keep it around.)

@jonathanknowles jonathanknowles self-requested a review June 6, 2019 06:55
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a given filename, it just uses the in-memory database.

Just to confirm that my understanding is correct, is this in-memory database supposed to be in-memory-SQLite?

I found the following snippet:

createSqliteBackend :: Maybe FilePath -> LogFunc -> IO SqlBackend
createSqliteBackend fp logFunc = do
    conn <- Sqlite.open (sqliteConnStr fp)
    enableForeignKeys conn
    wrapConnection conn logFunc

sqliteConnStr :: Maybe FilePath -> Text
sqliteConnStr = maybe ":memory:" T.pack  

With this change, is there any way to specify the MVar database on startup? (Not sure if we want to keep it around.)

@piotr-iohk
Copy link
Contributor

It would be nice to add integration test for --database option.
Could be here -> https://github.com/input-output-hk/cardano-wallet/tree/master/lib/http-bridge/test/integration/Test/Integration/Scenario/CLI

@KtorZ
Copy link
Member

KtorZ commented Jun 6, 2019

Closing in favor of #377

@piotr-iohk -> Will enable integration tests on the file-based SQLite in another PR.

@KtorZ KtorZ closed this Jun 6, 2019
@KtorZ KtorZ deleted the rvl/sqlite-db-layer branch June 7, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants