How does one access DataGrip in PhpStorm? - phpstorm

It sounds like JetBrains "DataGrip" functionality is included with PhpStorm. (https://intellij-support.jetbrains.com/hc/en-us/articles/115000877044-DataGrip-FAQ). How does one access the DataGrip functionality from within PhpStorm? (For example I want to explore a sqlite/mysql database)
Is this the same as the "Database Navigator" plugin? (https://plugins.jetbrains.com/plugin/1800-database-navigator)

"DataGrip functionality" incudes:
Database toolwindow (Data Sources/DB connections, viewing DB structure)
Query console (edit and execute SQL statements)
Table/Query results viewer
Import into/Export from DB
DB diagrams
Search for DB objects from Search Everywhere
etc
You can check the following links from the PhpStorm Help and PhpStorm website:
Video overview (quite old, but still valid): https://www.youtube.com/watch?v=kjPbxVlPnSI
Introduction blog post (very old): https://blog.jetbrains.com/phpstorm/2012/11/sql-support-and-database-tools/
Database tools and SQL (main entry): https://www.jetbrains.com/help/phpstorm/relational-databases.html
Connecting to SQLite DB: https://www.jetbrains.com/help/phpstorm/connecting-to-a-database.html#connect-to-sqlite-database
Database tool window: https://www.jetbrains.com/help/phpstorm/database-tool-window.html
Query console: https://www.jetbrains.com/help/phpstorm/query-console.html

Related

User friendly Mac OS Tool for viewing and editing mySQL data

I'm searching for a way to display mySQL DB Data offline on my mac. What I need is a (free or cheap) Tool where I can display, filter, search and edit a list/view of db data (selected via an sql query). A DB Administration tool can do this, but not user friendly.
A great existing tool is metabase but I don't need the functional scope and you cannot edit data there.
Any help is welcome! Thanks!

Phpmyadmin vs Jetbrains Datagrip for database management

I have been working with Phpmyadmin for quite some time and recently i came across Jetbrains Phpstorm and Intellij which i both really liked.
Now i found the database environment Datagrip.
I wanted to know objectively:
what are the advantages of Datagrip over Phpmyadmin and vice versa.
What does Datagripgive me that Phpmyadmin lacks?
What does Phpmyadmin give me that Datagrip lacks?
I am using PhpStorm and Datagrip since February 2017. Before that I was using Dreamweaver and PhpMyAdmin.
The only thing PhpMyAdmin had an advantage over Datagrip from my perspective, was searching the whole database. But since 2019 Datagrip has a "full text search" which does exactly the same.
Furthermore:
Datagrip is fully integrated into your IDE (PhpStorm, PyCharme, IntelliJ, etc). You don't need to leave it to run any SQL queries.
within the SQL console you have access to the "live templates" which let you insert huge code snippets impossible to remember via typing a few letters of the live template name. Before:
after:
SQL consoles are saved automatically (by a consecutive number). And you can save them as SQL files to any directory right from the console via ctrl/cmd + s
you also have access to the IDE's huge clipboard with (in my case) 100 previously copied text pieces, while each of them can be a whole (SQL) document:
it so easy to modify a table without writing any queries (table name, column name, foreign keys, indexes, column data type, etc):
the tables and search results are super easy to edit and update as if you would edit an Excel table
you can assign to /setup on any project as many databases as you like and access them easily
you can assign/setup and access any remote database via an SSH tunnel
you can assign/setup any type of DBMS:
Datagrip checks the SQL query syntax live, before you even run it
this is my IDE setup for testing query time on two identical sites running on different server setups (the one on nginx/mysql and the other one on Openlitespeed/Mariadb):
All that you get only for a couple of bucks! I pay now for PhpStorm only 80€ annually! I pay often much more for a single site license of some shitty wordpress plugin! But get a really really high quality software product with PhpStorm. Seriously, probably the only company I would LOVE to work as employee (being freelancer throughout my whole dev "career") is probably JetBrains. It seems as they can read my thoughts :D. Sure there are some few minor issues. But any time they bring out a new version I am excited as a child.
No I'm not paid by JetBrains :D And no I don't hype them because I'm Russian. At the time I felt in love with them I thought it is a Czech company with a bunch of Russian devs (nothing unusual in Europe). And Czech's in general don't like Russians. So I loved them even I thought they wouldn't love me :D Only a year after I've switched from Dreamweaver to PhpStorm I've found out it is a fully Russian company.
The only thing I hate in Datagrip is that the SQL console output shares for any reason a tab/window with Docker (dafuq?) and it is a huge pain in the as* to navigate between multiple query outputs/results (as in the example above where I compare the performance of two servers)
Update:
the only flaw of Datagrip from my perspective (pain in the as* to switch between console outputs) has gone now as well! :D
I've found a setting by which you can just simply open a "services" tree (Command + Shift + T) which list all the active/latest "services". I still don't understand why the Datagrip console output doesn't have a dedicated window, but at least I can now navigate easily between the different console's output:
What does Datagripgive me that Phpmyadmin lacks?
DataGrip provides fast code completion, based on the syntax — it can even complete your JOIN clause based on foreign keys.
It also has data editor — so you can edit several cells at once or you can edit many rows locally and then submit them.
Also you can navigate inside the grid y foreign keys.
Multi-cursor in the editor can help you edit a bunch of statements.
What does Phpmyadmin give me that Datagrip lacks?
PhpMyAdmin can export to PDF, ISO/IEC 26300 - OpenDocument Text and Spreadsheet, Word, LATEX
PhpMyAdmin has more administration features, dataGrip is not focused at administration at all
It also supports working with user accounts and privileges

How to do a query in Mysql WorkBench?

I have an .sql script that contains inserts and creates tables. I used the "Create EER Model From Script"
It created the tables but I can't see the data inside these tables.
I went to the query menu and tried to make a query but it gives me an error about not being able to connect to localhost.
Am I doing it right?
As documented under Create EER Model from SQL Script:
Clicking this action item launches the Reverse Engineer SQL Script wizard. This is a multi-stage wizard that enables you to select the script you want to create your model from.
For further information, see Section 7.7.9.1, “Reverse Engineering Using a Create Script”.
Following that link:
However, if you are working with a script that also contains DML statements you need not remove them; they will be ignored.
Instead, you want the Manage Data Import/Export option under Server Administration (within the Workspace section of the Home window).
You are confusing things here. Creating a model from a script is a process where meta data is examined and a model is created that you can then use to modify your schema structure, further design your db objects and all that. Modeling is a design process for the structure of your schema/db so it only deals with meta data. It's also used for documentation (e.g. in teams).
On the other hand there's normal sql work with existing db objects and/or actually creating/deleting/modifying db objects. In order to do the latter you must have an understanding of the design of the schema (which you could get by using the modeling part of MySQL Workbench, but not only by that). This is also the place to load a script, run it to insert data and such.
The error you mentioned regarding the connection is yet another problem and you need to solve this first to be able to even access your server. And yes, you have to install a server first somewhere. MySQL Workbench is a tool to visually work with your server(s) in opposition to the MySQL command line client which is a pure text interface (but still also a client application for your MySQL servers).
If you are on Windows and want a MySQL server installed locally (e.g. for testing) your best option is to download the MySQL Installer which greatly simplifies installing any of the tools from the MySQL family (server, client tools, connectors, documentation and more).

Quickstart database migration using Talend

I have this requirement to migrate a live SQL server 2008 to MySQL server 5, I have tried the MySQL migration toolkit but its throwing lots of migration errors. Someone here in Stackoverflow suggested that I use Talend. I installed Talend Open Studio for Data Integration but its quite a general purpose tool that there's no quickstart to do database migration like what I really needed.
Where can I find a quickstart guide to use Talend for such job?
Talend is quite generic data integration tool, but you should get the job done by following these steps (which actually apply to any database-types: PostgreSQL, Oracle, etc.):
Create a new database connection in Repository-panel, to the Metadata-"Db Connections"-node. Name it and select "DB Type" as "Microsoft SQL Server" (or whatever is your source database) and give the connection details.
Create another new database connection, but this time as "MySQL" (or whatever is your target database).
Create a new job to "Job designs" (in Repository).
Expand the "SQL Server"-DB-connection from the Metadata, and drag the desired table (under "Table schemas") to the work-area of the job AND select tMSSqlInput.
Drag the MySQL-DB-connection from the Metadata to the work-area AND select tMysqlOutput. Define the target table.
Click Palette and drag tMap component to the work-area between the two previous components.
Connect tMSSqlInput to tMap and tMap to tMysqlOutput with arrows. You do that by right-clicking the tMSSqlInput, selecting Row-Main and dragging the arrow to the tMap. Same from tMap to tMysqlOutput.
Double-click the tMap, select all columns from the left and drag them to the right. The tMap component allows you to make data transformations. It might be that you wouldn't even need to use the tMap between the database-components. But it is good to have just in case.
Run the job, and troubleshoot as necessary. If something goes wonky, restart Talend Studio or just close and open the job, in many occasions it helps.
The MySQL Migration Toolkit is deprecated long time ago. You should try the new Migration Wizard that comes with MySQl Workbench 5.2.41. It will help you to migrate both the tables and their data. You can have an overview of its capabilities here:
How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench
If you need to get started with Talend, I can suggest you check our documentation page http://www.talend.com/resources/documentation.php , where you will be able to find installation guides and user manuals.
Also, there's an interesting section on our website where you will be able to check out our tutorials, that should help out: http://www.talendforge.org/tutorials/menu.php
xybrek, unfortunately there's no tutorial that covers your specific case exactly.
Download the manuals that Bart linked to and start trying things out in Talend.
The components you'll be looking at are:
tMssqlInput - reads a table in a MsSQL db
tMySQLOutput - directs a flow of data, say the output of the mssqlinput component, into a mysql table
tMySQLRow - lets you execute a query on a mysql table/database
And possibly others. These are just some pointers to the more obvious components.
You can read more about those and see examples in the Reference Guide manual which covers all components in Talend.
Good luck!

How to generate the whole database script in MySQL Workbench?

I want to take the whole database. Where do I find the database file?
And is there a way to write the whole database with all data to a text file (like the one in SQL Server)?
How to generate SQL scripts for your database in Workbench
In Workbench Central (the default "Home" tab) connect to your MySQL instance, opening a SQL Editor tab.
Click on the SQL Editor tab and select your database from the SCHEMAS list in the Object Browser on the left.
From the menu select Database > Reverse Engineer and follow the prompts. The wizard will lead you through connecting to your instance, selecting your database, and choosing the types of objects you want to reverse engineer.
When you're all done, you will have at least one new tab called MySQL Model. You may also have a tab called EER Diagram which is cool but not relevant here.
Click in the MySQL Model tab
Select Database > Forward Engineer
Follow the prompts. Many options present themselves, including Generate INSERT Scripts for Tables which allows you to script out the data contained within your tables (perfect for lookup tables).
Soon you will see the generated script in front of you. At this point you can Copy to Clipboard or Save to Text File.
The wizard will take you further, but if you just want the script you can stop here.
A word of caution: the scripts are generated with CREATE commands. If you want ALTER you'll have to (as far as I can tell) manually change the CREATEs to ALTERs.
This is guaranteed to work, I just did it tonight.
Q#1: I would guess that it's somewhere on your MySQL server?
Q#2: Yes, this is possible. You have to establish a connection via Server Administration. There you can clone any table or the entire database.
This tutorial might be useful.
EDIT
Since the provided link is no longer active, here's a SO answer outlining the process of creating a DB backup in Workbench.
In MySQL Workbench 6, commands have been repositioned as the "Server Administration" tab is gone.
You now find the option "Data Export" under the "Management" section when you open a standard server connection.
there is data export option in MySQL workbech
I found this question by searching Google for "mysql workbench export database sql file". The answers here did not help me, but I eventually did find the answer, so I am posting it here for future generations to find:
Answer
In MySQLWorkbench 6.0, do the following:
Select the appropriate database under MySQL Connections
On the top-left hand side of screen, under the MANAGEMENT heading, select "Data Export".
Here is a screenshot for reference:
None of these worked for me. I'm using Mac OS 10.10.5 and Workbench 6.3. What worked for me is Database->Migration Wizard... Flow the steps very carefully
In the top menu of MySQL Workbench click on database and then on forward engineer. In the options menu with which you will be presented, make sure to have "generate insert statements for tables" set.
Try the export function of phpMyAdmin.
I think there is also a possibility to copy the database files from one server to another, but I do not have a server available at the moment so I can't test it.
Using Windows 10 and MySql Workbench 8.0
Go to Server tab
Go to Database Export
This opens up something like this
Select the schema to export in the Tables to export
Click the button Start Export
Surprisingly the Data Export in the MySql Workbench is not just for data, in fact it is ideal for generating SQL scripts for the whole database (including views, stored procedures and functions) with just a few clicks. If you want just the scripts and no data simply select the "Skip table data" option. It can generate separate files or a self contained file. Here are more details about the feature: http://dev.mysql.com/doc/workbench/en/wb-mysql-connections-navigator-management-data-export.html
in mysql workbench server>>>>>>export Data
then follow instructions it will generate insert statements for all tables data each table will has .sql file for all its contained data