Home
About
SQL code
Python code
Data view
Connection
Login
How to
Code generators
About
SQL Code
Python Code
Data View
Connection
Start
How To
MySQL easy:
MySQL easy is a tool to augment your database development.
It is an intelligent code generator. It generates code for you in SQL or in Python based on your table structure and relationships between the table. This tool will help debug larger database applications easily and write code in a matter of clicks that you may have required a few days of effort.
Start with setting your database connection information on the "Connection" tab. If connected properly, it will show you your database schemas, tables, views and stored procedures on the left side navigation. Select a table and click on SQL code or Python code tabs. You can either copy code or save a file. This code is based on a python package named mysqleasy. You can download it by running "pip install mysqleasy" on your command shell.
SQL code:
Sample code that you can use to create a table named user with three columns user_id, last_name and first_name. After creating this table reconnect to database and select the user table. Save the auto generated code.
*
Copy to clipboard
CREATE TABLE `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(70) DEFAULT NULL, `last_name` varchar(70) DEFAULT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
max 3000 chars
Python code:
Following code will insert a new user John Smith. Then search the records with last name Smith. Then update the first name to Mike in the first row. Update the records in database and at the end close the connection.
*
Copy to clipboard
from mysqleasy import ObjectDict from mysqleasy.Connection import Connection as Connection from mysqleasy.Access import Access as Access connector = "mysqlconnector" db_config = {'host': 'your_database_host_address', 'user': 'your_database_user_name', 'password': 'your_database_password'} conn = Connection.create(connector, db_config) last_row_id = user.insert(conn, first_name = "John", last_name = "Smith") columns, users = user.search(conn, last_name='Smith') user_list = [o for o in Access.iter_object(columns, users)] last_row_id, count_affected = user.insertupdate_multiple(conn, [('Mike', 'Smith', 1)]) conn.commit() conn.close()
max 3000 chars
Stored Procedure
View
Table
Save File
Copy to clipboard
Auto Code:
File name:
max 3000 chars
Save File
Copy to clipboard
Auto Code:
File name:
max 2550 chars
SQL:
*
Execute
Host:
max 100 chars
User name:
max 100 chars
Password:
max 100 chars
Connect
Troubleshooting tip: if you are unable to connect to your database, make sure that your firewall allows our IP address 159.89.37.150 .
User name:
max 100 chars
Password:
max 100 chars
You will need an account to see the Data View and dependency tracker.
Please
create an account
.
Login
Logout
First, install MySQL easy using "pip install mysqleasy".
Connectors & connection:
You need to setup your connectors. Just set your connector variable to the string name of connector. Available connectors are :
mysqlconnector
pyodbc
pymysql
MySQLdb
Here we are using mysqlconnector. You can install it using "pip install mysqlconnector".
Step
1
Copy to clipboard
from mysqleasy import ObjectDict from mysqleasy.Connection import Connection as Connection from mysqleasy.Access import Access as Access connector = "mysqlconnector" db_config = {'host': 'your_database_host_address', 'user': 'your_database_user_name', 'password': 'your_database_password'} conn = Connection.create(connector, db_config)
max 3000 chars
Searching:
To select filtered data, you can use the search method of the auto generated class as follows. It returns two objects. First one is the columns information. Second object is a python generator object which acts like a cursor in older style programming. You can specify any column as a filter. Following example shows if you want to search by last name. You can specify any number of columns as filters. If you want to filter with a like statement in SQL then just append '%' to your search string.
Step
2
Copy to clipboard
columns, users = user.search(conn, last_name='Smith')
max 3000 chars
Iterating results:
Using both columns and data objects you can loop over the rows of data and get the data in a list using following list comprehension.
Step
3
Copy to clipboard
user_list = [o for o in Access.iter_object(columns, users)]
max 3000 chars
Inserting one row:
The "insert" method of the class takes connection object as parameter just like the search method. The rest of the parameters are column names of the table. Make sure to provide atleast required not NULL columns. This function returns id of the last inserted row.
Another method available to you is "insert_many". Along with connection object it takes a collection of user objects to insert. This method returns last inserted row id and number of rows inserted.
Step
4
Copy to clipboard
last_row_id = user.insert(conn, first_name = "John", last_name = "Marc")
max 3000 chars
Save multiple rows:
The "insertupdate_multiple" method of the class takes connection object as parameter just like the search method. It takes a collection of user objects to insert. This method returns last inserted row id and number of rows inserted.
Step
5
Copy to clipboard
last_row_id, count_affected = user.insertupdate_multiple(conn, [('Mike', 'Smith', 1)])
max 3000 chars
Close connection:
The last step is to close your connection object. You can use transactional features of Connection objects if you want to commit or rollback your insert or updates.
Step
6
Copy to clipboard
conn.commit() conn.close()
max 3000 chars
Users
2
Alerts
7
More
Alerts
Notifications
Activities
Settings
Staff
8
Bob Nilson
Project Manager
Nick Larson
Art Director
3
Deon Hubert
CTO
Ella Wong
CEO
Customers
2
Lara Kunis
CEO, Loop Inc
Last seen 03:10 AM
new
Ernie Kyllonen
Project Manager,
SmartBizz PTL
Lisa Stone
CTO, Keort Inc
Last seen 13:10 PM
7
Deon Portalatin
CFO, H&D LTD
Irina Savikova
CEO, Tizda Motors Inc
4
Maria Gomez
Manager, Infomatic Inc
Last seen 03:10 AM
Back
Bob Nilson
20:15
When could you send me the report ?
Ella Wong
20:15
Its almost done. I will be sending it shortly
Bob Nilson
20:15
Alright. Thanks! :)
Ella Wong
20:16
You are most welcome. Sorry for the delay.
Bob Nilson
20:17
No probs. Just take your time :)
Ella Wong
20:40
Alright. I just emailed it to you.
Bob Nilson
20:17
Great! Thanks. Will check it right away.
Ella Wong
20:40
Please let me know if you have any comment.
Bob Nilson
20:17
Sure. I will check and buzz you if anything needs to be corrected.
General
You have 4 pending tasks.
Take action
Just now
Finance Report for year 2013 has been released.
20 mins
You have 5 pending membership that requires a quick review.
24 mins
New order received with
Reference Number: DR23923
30 mins
You have 5 pending membership that requires a quick review.
24 mins
Web server hardware needs to be upgraded.
Overdue
2 hours
IPO Report for year 2013 has been released.
20 mins
System
You have 4 pending tasks.
Take action
Just now
Finance Report for year 2013 has been released.
20 mins
You have 5 pending membership that requires a quick review.
24 mins
New order received with
Reference Number: DR23923
30 mins
You have 5 pending membership that requires a quick review.
24 mins
Web server hardware needs to be upgraded.
Overdue
2 hours
IPO Report for year 2013 has been released.
20 mins
General Settings
Enable Notifications
Allow Tracking
Log Errors
Auto Sumbit Issues
Enable SMS Alerts
System Settings
Security Level
Normal
Medium
High
Failed Email Attempts
Secondary SMTP Port
Notify On System Error
Notify On SMTP Error
Save Changes