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

Load database error #50

Closed
glepnir opened this issue Aug 3, 2020 · 29 comments
Closed

Load database error #50

glepnir opened this issue Aug 3, 2020 · 29 comments

Comments

@glepnir
Copy link
Contributor

glepnir commented Aug 3, 2020

Hi @kristijanhusak
I use three different database connections, but after opening dadbod, I found that they are all connected to mysql.
the echo g:dbs

{'jianshu':'mysql://root@localhost/jianshu','ginweb':'mysql://root@localhost/ginweb'}

image

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Hi @kristijanhusak any update for this issue?

@kristijanhusak
Copy link
Owner

@glepnir I'll look into this. Did you try declaring different formats to see if it works?
For example, try something like this to see if you get the same results:

  let g:dbs = [
  \ { 'name': 'jianshu', 'url': 'mysql://root@localhost/jianshu' }
  \ { 'name': 'ginweb', 'url': 'mysql://root@localhost/ginweb' },
  \ ]

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

@kristijanhusak I already tried it. the result is same.

@kristijanhusak
Copy link
Owner

@glepnir as far as I know, in MySQL, all databases belong to the same schema. From your screenshot, I see both databases in both connections.
How would you expect it to work?

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

@kristijanhusak you can see the crawler and ginweb both connect to mysql db. not ginweb database

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

I tried the dadbod DB mysql://root@localhost/ginweb. it's only connect to ginweb database.

@kristijanhusak
Copy link
Owner

kristijanhusak commented Aug 12, 2020

@glepnir all mysql databases belong to mysql db, that's why you see them in both connections.
Schemas are fetched from this query:

SELECT schema_name FROM information_schema.schemata

What would you expect to see in "Schemas" when you connect to specific database?

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

To be honest, this statement is correct. It will return all databases in mysql。But just like the connected url. We want to connect to a certain database.Any current mysql connection url returns the entire mysql database.
This is strange. Why do we need to specify a certain database in the URL? Even if it is specified, it loses meaning. Because we still see all the databases in mysql.

ginweb: mysql://root@localhost/ginweb  same as mysql:mysql@localhost/mysql
crawler: mysql://root@localhost/crawler  same as mysql:mysql@localhost/mysql

@kristijanhusak
Copy link
Owner

@glepnir I don't think you have to. Doing mysql://root@localhost should be enough.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Ok. But this is not important. What I want to say is that even if we connect to the specified database through the URL, the result is still the entire mysql database.

@kristijanhusak
Copy link
Owner

@glepnir Yes, that's true. That's why I ask, what would you expect to be listed under 'Schemas' in drawer when you are connected to specific database?

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Obviously I only want to see information about this database. Maybe like this? ginweb: mysql://root@localhost/ginweb
image

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

It looks like we need to query the views functions tables from schemes. I don't know the specific implementation. If we can't achieve it. I think we need to modify the readme and doc to remind other users. Any URL in mysql will return the entire mysql database. To avoid more trouble

@kristijanhusak
Copy link
Owner

@glepnir pull latest and give it a test.
It should print out whole mysql db only if url doesn't have specified db (mysql://root@localhost).
If db is specified, it should show only tables.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

It looks good, but can there be 2 tables hidden?
image

@kristijanhusak
Copy link
Owner

kristijanhusak commented Aug 12, 2020

Can you give me output of this:

:echo db#adapter#mysql#tables('mysql://root@localhost/ginweb')

I want to see what's that warning.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Here is warning.
image

@kristijanhusak
Copy link
Owner

kristijanhusak commented Aug 12, 2020

@glepnir I edited my comment. I initially added the password for root. Do this:

:echo db#adapter#mysql#tables('mysql://root@localhost/ginweb')

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Can you give me output of this:

:echo db#adapter#mysql#tables('mysql://root@localhost/ginweb')

I want to see what's that warning.

:echo db#adapter#mysql#tables('mysql://root@localhost/ginweb') this command same as pre command? The output is same as pic ? Do i need update the dadbod-ui?

@kristijanhusak
Copy link
Owner

@glepnir put whatever you put for url in dadbod-ui.
From screenshot it looks like you provided a password for root, but you are not using any password.
If you are using password for root, do it like this:

:echo db#adapter#mysql#tables('mysql://root:YOURPASSWORD@localhost/ginweb')

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Got it .
image

@kristijanhusak
Copy link
Owner

@glepnir pull latest changes and give it a test.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

Does not hidden this in latest version?
image

@kristijanhusak
Copy link
Owner

@glepnir sorry, I don't get the warning, so I can't test it properly. Regex was wrong. Pull and test again.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

It still exist.

call filter(a:db.tables.list, 'v:val !~? "^mysql: \[Warning\]" && v:val !~? "^Tables_in_"')

What about this?

let a:db.tables.list = a:db.tables.list[2:len(a:db.tables.list)-1]

image

@glepnir glepnir mentioned this issue Aug 12, 2020
@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

I create a pr for this. please check thanks.

@kristijanhusak
Copy link
Owner

@glepnir it will not work. I wrote on PR why. Try to go to line 524 in drawer.vim and tweak the filtering.

@kristijanhusak kristijanhusak mentioned this issue Aug 12, 2020
@kristijanhusak
Copy link
Owner

@glepnir pull now and test. Closing square bracket wasn't escaped properly.

@glepnir
Copy link
Contributor Author

glepnir commented Aug 12, 2020

closed.

@glepnir glepnir closed this as completed Aug 12, 2020
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 a pull request may close this issue.

2 participants