赞
踩
指定pip从哪个源服务器下载和安装Python包
pip3 config set global.index-url
https://pypi.tuna.tsinghua.edu.cn/simple
yum -y install sqlalchemy
pip3 install pandas
from sqlalchemy import create_engineclass Python_Mysql(object):def __init__(self):print("test")def getEngine(seft):host=input("sign mysql server host:")username=input("sign mysql username:")password=input("sign mysql password:")databasename=input("sign database name:")port=input("sign mysql port:")engine=create_engine(f"mysql+pymysql://{username}:{password}@{host}:{port}/{databasename}")return enginedef querySql(self,conn):sql=input("sign your sql:")returnpd.read_sql(sql=sql,con=conn)if __name__=="__main__":demo=Python_Mysql()#sql=input("sign sql:")# sql="select * from user"rs=demo.querySql(demo.getEngine())print(rs)
pip3 config set global.index-url
https://pypi.tuna.tsinghua.edu.cn/simple
yum -y install pandas
yum -y install pymysql
>>> import pandas as pd
>>> import pymysql
>>> conn=pymysql.connect(... host='192.168.1.130',... user='dongdong',... password='1',... database='test',... port=3306... )>>> conn<pymysql.connections.Connection object at 0x7f9e24ba2c88>>>> cursor=conn.cursor()>>> cursor<pymysql.cursors.Cursor object at 0x7f9e24ba2668>>>> sql="select * from user">>> cursor.excute(sql)Traceback (most recent call last):File "<stdin>", line 1, in <module>AttributeError: 'Cursor' object has no attribute 'excute'>>> cursor.execute(sql)3>>> cursor.description(('id', 3, None, 11, 11, 0, False), ('username', 253, None, 180, 180, 0, False), ('password', 253, None, 180, 180, 0, False))>>> desc=cursor.description>>> res3>>> res=cursor.fetchall()>>> res((1, 'aaa', '123'), (8, 'baba', 'pipi'), (20, 'aaaaaaaa', 'bbbbbbbb'))>>> desc(('id', 3, None, 11, 11, 0, False), ('username', 253, None, 180, 180, 0, False), ('password', 253, None, 180, 180, 0, False))>>> [item[0] for item in desc]['id', 'username', 'password']>>> col=[item[0] for item in desc]>>> df=pd.DataFrame(res,columns=col)>>> dfid username password0 1 aaa 1231 8 baba pipi2 20 aaaaaaaa bbbbbbbb
总结
pip3 install pyinstaller
pyinstaller --onefile xxx.py
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。