在其他所有机器上,我都没有错误,但仅在centos7.6机器上,遵循简单的代码就会出错。
不知道是什么原因引起的,如何恢复系统?
from os.path import expanduser
import pymysql
import sshtunnel
from sshtunnel import SSHTunnelForwarder
import paramiko
from IPython.display import display
import pandas as pd
sshtunnel.SSH_TIMEOUT = 20.0
# Server config:
config_live1 = {
'ssh_user': 'user',
'ssh_host': 'ip address',
'ssh_port': 11111,
'sql_host': 'host address',
'sql_port': 11111,
'db_use': 'db'
}
# Client config
client_live = {
'user': 'user',
'pw': 'password',
}
#SSH Public/Private key
mypkeyfile = expanduser('~') + "/.ssh/id_rsa"
def sqlconnect(config, client):
tunnel = SSHTunnelForwarder(
ssh_address_or_host = (config['ssh_host']),
ssh_username= config['ssh_user'],
ssh_pkey = mypkeyfile,
remote_bind_address=(config['sql_host'], config['sql_port']))
tunnel.start()
cnx = pymysql.connect(host='127.0.0.1',
port= tunnel.local_bind_port,
user=client['user'],
passwd=client['pw'],
database=config['db_use'],
cursorclass = pymysql.cursors.DictCursor)
print('Welcome aboard! You are on ' + config['sql_host'] + ' with local port', tunnel.local_bind_port)
cur = cnx.cursor()
cur.execute('SHOW DATABASES')
print('Available DBs are:', cur.fetchall())
df_dict = {}
while True:
query = input('Write your query (or exit):')
if query == 'exit':
break
else:
cur.execute(query)
result = pd.DataFrame(cur.fetchall())
display(result)
print_out = input('Save as [DataFrame] OR [CSV] OR next:')
if print_out in ['DataFrame', 'Dataframe', 'dataframe', 'df']:
print(df_dict.keys())
df_name = input('Give the DataFrame name, but avoid above values:')
df_dict[df_name] = result
elif print_out in ['CSV', 'csv']:
result.to_csv(input('Give the CSV file name'))
if bool(df_dict) == True:
print('You have saved these dataframes:', df_dict.keys())
return df_dict
cnx.close()
#include <fstream>
int main()
{
std::ifstream file;
file.open("in.txt", std::ifstream::in);
return 0;
}