![]() ![]() (row=0,column=1,sticky=Tkinter.E+Tkinter.W) Self.label_id(row=1,column=0, sticky=Tkinter.E+Tkinter.W) Self.label_id(row=0,column=0,sticky=Tkinter.E+Tkinter.W) Self.label_password=Tkinter.Label(self.parent,text="DB Password:", anchor=Tkinter.W,background="dark slate gray",foreground="white", font="Helvetica 8 bold") Self.label_user=Tkinter.Label(self.parent,text="DB User: ",anchor=Tkinter.W,background="dark slate gray",foreground="white", font="Helvetica 8 bold") """Draw a user interface allowing the user to type The interface represented by the first screenshot is created by initialize_user_interface() function: def initialize_user_interface(self): ![]() Mysql> CREATE TABLE mystars(id INT(2) NOT NULL AUTO_INCREMENT, It will contains their names starname and an auto incrementing primary key id: mysql> USE begueradj Now it is time to create the table in which we save your favorite stars. I choose the simplest one, just to satisfy this immediate need: If the credentials are the right one, the user may then save/add his favorite starts to the database through a new window similar to the one you designed: If the credentials are wrong, the window still prompts itself there unless the user exists the application. Install the MySQL databse interface itself: sudo apt-get install python-mysqldb.įirst, we'll ask the user to type his credentials to MySQL server:.Install the needed dependencies: sudo apt-get install build-essential python-dev libmysqlclient-dev.But for Ubuntu, by my personal experience, I prefer to install it this way: The common way to install MySQLdb is to use pip as described here. How to install MySQLdb on Ubuntu 14.04.3 LTS? You can find a good comparison between these 2 interfaces here. That is also my favorite database interface I am going to use in what follows. For speed you need to choose the first one. For portability it is better to choose the later one. MySQLdb is rather a C library which makes it faster than MySQL connector which is a pure Python library. Which one is better to install? I prefer to talk only about 2 of them that I used myself: MySQLdb and MySQL connector. Here is the exhaustive list of Python MySQL databse interfaces. What tools do I need to use?įirst, you will need to to install a Python database interface that will allow you to communicate with MySQL server using Python. Whether you are using Tkinter or some other GUI package, the method to implement your goal remains the same. I assume you have already installed MySQL server on Ubuntu. I am going to guide you step by step to resolve your problem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |