Python API to delete selected rows in omnisci table
Hi,
I am connecting to omnisci table using python. Is there any API to remove certain rows based on condition on any column?
Thanks, Leelakrishna.
-
Hi @leelakrishna_gairubo,
Thanks for joining our community.
If you are using the heavyai python sqllibrary you have to specify the condition into the sql used to query the table or if you want delete rows from table you should use a sql delete statement.
If you need something similar to pandas you can try to use IBIS library, but I'm not sure if you can delete row from a table, but it should build the sql statements for aggregates, filtering and stuff like that.
https://docs.heavy.ai/data-science/introduction-to-ibis
Let me know if this replies to you question, because I'm not sure if I interpreted you question
Regards, Candido
-
To delete selected rows from an OmniSci table using Python, you can use the
pymapd
library which provides a Python API for interacting with OmniSci databases. Here's an example code snippet that shows how to delete rows that match a certain condition:import pymapd # connect to OmniSci database conn = pymapd.connect(user='your_username', password='your_password', host='your_host', dbname='your_database') # define condition for rows to be deleted condition = "column_name = 'value'" # delete rows that match the condition conn.execute("DELETE FROM table_name WHERE " + condition) # close the connection conn.close()
In this example, replace
your_username
,your_password
,your_host
, andyour_database
with your own database connection details. Also, replacecolumn_name
and'value'
with the name of the column and the value that you want to use as the condition for deleting rows. Finally, replacetable_name
with the name of the table that you want to delete rows from.Please visit: https://www.janbasktraining.com/online-python-training
Please sign in to leave a comment.
Comments
3 comments