How to use database plugin without first opening a superfluous project

已回答

How do I access the features of the database plugin without unnecessarily opening a [unrelated] project?

Al I want to do is to connect to a DB and write some scripts, but I cannot figure out how to get to that page without opening or creating a completely unrelated project first. If a project is absolutely necessary then why not have a DB project where I can keep my scripts organized? At the moment the scripts seem completely disconnected from the actual project, so why do I need the project at all?

IntelliJ IDEA 2017.2.5
Build #IU-172.4343.14, built on September 26, 2017
JRE: 1.8.0_152-release-915-b12 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

0

You can create an empty project then use Database tool window for creating a data source. But to store files in project you need to define the content root (i.e. create a module).

If you work only with databases, try DataGrip - more light-weigh IDE, designed solely for working with databases and sql. It creates the default project automatically for you:

>Your data source settings are stored in projects. When you start DataGrip for the first time, the project called default is created, and you work with that project unless you create another one (File | New | Project).

and you use Files view for managing your scripts.

0

Hi, Andrey, thanks for the reply.

"You can create an empty project then use Database tool window for creating a data source"
That is what I'm doing now, and it is annoying to have to do that for no real benefit.

I don't just work on databases. I work on the DB in concert with other development. Unfortunately I cannot use IJ for Android work because it is constantly out of sync with Android Studio, so this is currently the only feature I use while doing Android work. If I accidentally open my Android project in IJ then it downgrades it, which forces an upgrade (and VCS shenanigans) when opened in AS. So I have to run parallel projects, and manage the connection to the test device (or either AS or IJ ends up going wobbly).

I'm not considering purchasing a license to DataGrip because, as far as I can tell, it and IJ database plugin are basically the same thing so I suspect that the lack of organization that I find annoying in IJ's database plugin is continued in DataGrip.

I don't mind having to open a project to use the feature, if that project did something useful, but this is just creating a blank project for no benefit than getting around some peculiarities with IJ. I was hoping there was a way to just use the editor feature as a standalone so I can manage my scripts in my own way (e.g by product feature) .But it seems there is no easy way to just open/save SQL files.

The editing features are very nice, but there is no real organization. If I'm working on multiple scripts I often have to look at every open console to find the one I'm looking for. If I click on "Database Consoles" I get scripts listed from completely different projects. I don't see how to save a script with a name (there seems to be an auto save, but the names look like UUID/GUIDs or "[connection]_[number]" or "console[_number].sql"). The more projects you have and the more scripts you write the more difficult it is to find anything.  At the moment I find myself copying the finished script into another text editor just to save the script.


Having a "database project" option available in IntelliJ would help alleviate the annoyances. One where I can save a script associated with the specific project, and where I can organize scripts by folder or package (or some other hierarchical concept).

 

 

0

>That is what I'm doing now, and it is annoying to have to do that for no real benefit.

What workflow do you propose? You still need to store sql files under some directory, right? So since there is already a directory for the sql files why is it a problem to create a basic plain module for it (Web type) without any frameworks and use it as a storage location for your sql files and data sources (if you deside to store in with the project. Or store DS globally, see https://stackoverflow.com/a/42682728/2000323 ).

>I was hoping there was a way to just use the editor feature as a standalone so I can manage my scripts in my own way (e.g by product feature) .But it seems there is no easy way to just open/save SQL files.

Sounds like https://youtrack.jetbrains.com/issue/IDEABKL-5939


>If I'm working on multiple scripts I often have to look at every open console to find the one I'm looking for.

There is Autoscroll to/from Editor option: when you switch to particular tab editor it will auto open corresponding database console:



You can also use Database colors to mark each data source, database or schema with each color if you use many databases/schemas: https://www.jetbrains.com/help/datagrip/database-color-settings-dialog.html


>If I click on "Database Consoles" I get scripts listed from completely different projects. I don't see how to save a script with a name (there seems to be an auto save, but the names look like UUID/GUIDs or "[connection]_[number]" or "console[_number].sql").

Could you attach a screenshot?

0

请先登录再写评论。