外部PCから仮想サーバ(192.168.84.130)へSSHでPythonコードを実行
C:\Users\[外部PCユーザ名]>ssh [仮想サーバのユーザ名]@192.168.84.130 python C:\Users\[仮想サーバのユーザ名]\Desktop\import_fdb_py32.py
[仮想サーバのユーザ名]@192.168.84.130's password:
('USA', 'Dollar')
('England', 'Pound')
('Canada', 'CdnDlr')
('Switzerland', 'SFranc')
('Japan', 'Yen')
('Italy', 'Lira')
('France', 'FFranc')
('Germany', 'D-Mark')
('Australia', 'ADollar')
('Hong Kong', 'HKDollar')
('Netherlands', 'Guilder')
('Belgium', 'BFranc')
('Austria', 'Schilling')
('Fiji', 'FDollar')
PythonコードはFirebirdのsampleを見るコード
import fdb
# Firebirdデータベースへの接続情報を指定します
dsn = "192.168.84.130:C:\soft\Firebird\Firebird_2_0\examples\empbuild\employee.fdb"
# 'localhost/3050:/path/to/database.fdb'
user = 'SYSDBA'
# 'your_username'
password = 'masterkey'
# 'your_password'
# Firebirdデータベースに接続します
con = fdb.connect(dsn=dsn, user=user, password=password)
# クエリを実行します
cursor = con.cursor()
cursor.execute("SELECT * FROM COUNTRY")#("SELECT * FROM your_table")
result = cursor.fetchall()
# 結果を表示します
for row in result:
print(row)
# 接続を閉じます
con.close()