You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a NumPy array of values that I would like to put into Scylla. When I use np.ndarray.astype(SmallInt) it succeeds, but I get a marshalling error when I try to upload the data.
I am guessing that there is a lack of support for these types in scyllapy. I expect it to be a simple solution considering NumPy has Rust bindings.
The text was updated successfully, but these errors were encountered:
Hi. I don't think that supporting such types is inside the scope of the driver. Here's an example of how you can insert numpy array in your database without any issue.
importasynciofromscyllapyimportScyllafromscyllapyimportextra_typesimportnumpyasnpasyncdefmain():
scylla=Scylla(
contact_points=["localhost"],
)
awaitscylla.startup()
awaitscylla.execute(
"CREATE KEYSPACE IF NOT EXISTS test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
)
awaitscylla.execute(
"CREATE TABLE IF NOT EXISTS test.test (id int, data LIST<SMALLINT>, PRIMARY KEY (id));"
)
awaitscylla.execute("TRUNCATE test.test;")
arr=np.array(range(10), dtype=np.int8)
data=list(map(extra_types.SmallInt, arr)) # <-- Here's how you can convert numpy array to Scylla typeawaitscylla.execute("INSERT INTO test.test (id, data) VALUES (1, ?);", (data,))
res=awaitscylla.execute("SELECT * FROM test.test;")
print(res.all())
if__name__=="__main__":
asyncio.run(main())
I think scope is purely defined by you; if you say it is within scope it would be. We wouldn't depend on numpy on the Python side, but on the rust side only. The type mapping would be in scope because you are mapping to types defined in this package.
I have a NumPy array of values that I would like to put into Scylla. When I use
np.ndarray.astype(SmallInt)
it succeeds, but I get a marshalling error when I try to upload the data.I am guessing that there is a lack of support for these types in
scyllapy
. I expect it to be a simple solution consideringNumPy
has Rust bindings.The text was updated successfully, but these errors were encountered: