Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C csvkit
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wireservice
  • csvkit
  • Issues
  • #649
Closed
Open
Issue created Aug 05, 2016 by Administrator@rootContributor

csvsql fails with misleading error if query and dialect are specified with no connection_string

Created by: chisco50

Behavior If I try to run csvsql with "dialect", "query" and no "connection_string", it will fail with a "The --dialect option is only valid when --db is not specified."

Cause: Given that both "query" and "dialect" are being used, the run enters the following block which sets a default connection_string

# Create an SQLite database in memory if no connection string is specified```
        if query and not connection_string:
            connection_string = "sqlite:///:memory:"
            do_insert = True```

Then, the following block will always raise the error as there is now a connection string and a dialect:

if self.args.dialect and connection_string:
            self.argparser.error('The --dialect option is only valid when --db is not specified.')

Suggestion: Refactor the code (csvsql.py). One quick possibility is to call the block that raises the error before the block that sets the default connection string.

Assignee
Assign to
Time tracking