I want to run a blaze server which mounts two data sources, one postgreSQL table and one CSV file, but I dont know how can I mount more than one data source on blaze server.
I have the following code on server side:
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)
and in the client side:
source =Data('blaze://localhost:6363/')
t=symbol('t', source.dshape)
expr=t[t.color=='K']
result=compute(expr, Data(source))
how can I mount another data source like CSV file or another table of the database on the same blaze server? for example:
csv= Data('.\data.csv', sep=';', has_header=True)
Update:
I had to add the data sources as dictionary to my server,
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
}
I got the answer to this question from here:
https://github.com/blaze/blaze/issues/1631
The standard way to do this would be to make the server's resource a dictionary of other resources. I updated the question.