In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Index.py, this is just assuming a simulated landing.
#-*-coding: utf-8-*-"Created on Sun Nov 27 18:54:29 2016 this is the main program file @ author: toby" from model.user import Userdef main (): username = "tantianran1" user = User () result = user.Check_Username (username) if not result: print 'user does not exist Please log in 'else: print' login succeeded'if _ _ name__ = = "_ _ main__": main ()
User.py
#-*-coding: utf-8-*-"" Created on Sun Nov 27 19:48:03 2016 processing of database tables, py file name and table name correspond one to one, so The user.py file here is the processing of database table user @ author: toby "" import syssys.path.append ("/ home/toby/workspace/date20161128") from utility.sql_helper import MysqlHelperclass User (object): def _ _ init__ (self): self.__helper = MysqlHelper () def Get_data_by_id (self,ids): sql = "select * from user where id=%s" params = (ids ) return self.__helper.Get_One_Data (sql,params) def Check_Username (self,name): sql = "select * from user where name=%s" params = (name,) return self.__helper.Get_One_Data (sql,params)'a = User () print a.Check_Username ('tantianran')''
Sql_helper.py
#-*-coding: utf-8-*-"Created on Sun Nov 27 18:57:44 2016 data processing layer, the lowest layer of data processing For example, the function @ author: toby "import MySQLdbclass MysqlHelper (object): def _ _ init__ (self): hosts,users,password,dbname = '127.0.0.1." Params): self.cur.execute (sql,params) data = self.cur.fetchall () # fetchall () get all data self.cur.close () self.conn.close () return data def Get_One_Data (self,sql,params): self.cur.execute (sql) Params) data = self.cur.fetchone () # fetchone () is to get a piece of data self.cur.close () self.conn.close () return data
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.