Python 向blaze服务器添加数据源
我想运行一个blaze服务器,它装载两个数据源,一个postgreSQL表和一个CSV文件,但我不知道如何在blaze服务器上装载多个数据源 我在服务器端有以下代码:Python 向blaze服务器添加数据源,python,blaze,Python,Blaze,我想运行一个blaze服务器,它装载两个数据源,一个postgreSQL表和一个CSV文件,但我不知道如何在blaze服务器上装载多个数据源 我在服务器端有以下代码: engine = create_engine('postgresql://user:pass@localhost:5432/mydb') with engine.connect() as conn: metadata=MetaData() metadata.bind=engine t=Table('t',
engine = create_engine('postgresql://user:pass@localhost:5432/mydb')
with engine.connect() as conn:
metadata=MetaData()
metadata.bind=engine
t=Table('t', metadata, autoload=True, autoload_with=conn)
server=bz.Server(t)
server.run(host='0.0.0.0', port=6363)
在客户端:
source =Data('blaze://localhost:6363/')
t=symbol('t', source.dshape)
expr=t[t.color=='K']
result=compute(expr, Data(source))
如何在同一blaze服务器上装载另一个数据源,如CSV文件或数据库的另一个表?
例如:
csv= Data('.\data.csv', sep=';', has_header=True)
更新:
我不得不将数据源作为字典添加到我的服务器
engine = create_engine('postgresql://qfsa:123@localhost:5433/mydb')
with engine.connect() as conn:
metadata=MetaData()
metadata.bind=engine
table1=Data(Table('tablename1', metadata, autoload=True, autoload_with=conn))
table2=Data(Table('tablename2', metadata, autoload=True, autoload_with=conn)
csvfile=Data('.\data.csv', sep=';', has_header=True)
resources={
'table1': table1,
'table2': table2,
'csvfile': csvfile
}
我从这里得到了这个问题的答案: 实现这一点的标准方法是使服务器的资源成为其他资源的字典。我更新了问题