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

sq should be able to work with datasources defined in-line #3

Open
neilotoole opened this issue Oct 9, 2016 · 3 comments
Open

sq should be able to work with datasources defined in-line #3

neilotoole opened this issue Oct 9, 2016 · 3 comments

Comments

@neilotoole
Copy link
Owner

Currently one must do sq add DS and then reference the data source in a later command. It should be possible to refer to data sources in-line, e.g.

sq '@myhandle:mysql://user:pass@localhost:3306/mydb1 @myhandle.users | .uid, .email'

# or (without specifying a handle)

sq '@:mysql://user:pass@localhost:3306/mydb1 .users | .uid, .email'
@neilotoole
Copy link
Owner Author

This is still a possibility. The post recent proposed syntax on this would be:

$ sq '@(mysql://user:pass@localhost/sakila)' | .actor | .[0:10]

$ sq '@(./path/to/sakila.xlsx).actor'

However, for file-based formats there is less of a need for this anymore due to the ability to do:

$ cat sakila.xlsx | sq .actor

@c-nv-s
Copy link

c-nv-s commented Jun 20, 2023

I want to also mention that as a Postgres user, another reason why this feature would make life a lot easier and more versatile is by facilitating the querying of different schemas on the same database more easily.

at present you also have to add each schema as a different src i.e.

sq add 'postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer1'
sq add 'postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer2'
sq add 'postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer3'

whereas it would be a lot easier sometimes to just call

sq '@(postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer1)' | .customer_name
sq '@(postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer2)' | .customer_name

...or maybe overriding the schema with a flag could also work

sq add 'postgres://sakila:p_ssW0rd@localhost/sakila'
sq --search-path customer1 '.customer_name'
sq --search-path customer1 '.customer_name'

...not sure what the equivalent to schemas/namespacing in other databases are so as to try and keep it as generic as possible.

@neilotoole
Copy link
Owner Author

@c-nv-s I agree. I'd like to implement both mechanisms. The flag is probably the lowest effort to implement. I've created a separate issue for it.

Thanks for the feedback, keep it coming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants