<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Row INSERT into table does not persist in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/row-insert-into-table-does-not-persist/m-p/51212#M29007</link>
    <description>&lt;P&gt;HI,&amp;nbsp;&lt;/P&gt;&lt;P&gt;are you closing connection at the end?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;cursor&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;close&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt;
&lt;SPAN class=""&gt;connection&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;close&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Also, can you elaborate what you mean by saying "&lt;SPAN&gt;when I reload the table"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2023 21:01:04 GMT</pubDate>
    <dc:creator>Emil_Kaminski</dc:creator>
    <dc:date>2023-11-13T21:01:04Z</dc:date>
    <item>
      <title>Row INSERT into table does not persist</title>
      <link>https://community.databricks.com/t5/data-engineering/row-insert-into-table-does-not-persist/m-p/51166#M28996</link>
      <description>&lt;P&gt;I have this script:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from databricks import sql
import os
import pandas as pd

databricksToken = os.environ.get('DATABRICKS_TOKEN')

connection = sql.connect(server_hostname = "",
                 http_path       = "",
                 access_token    = databricksToken)

def databricks_write(name, racf, action):
  global connection  # Use the global connection variable
  cursor = connection.cursor()
  df = pd.DataFrame({'operatorName': name, 'racf': racf, 'action': action, 'datetime': [pd.Timestamp.now()]})
  columns = ', '.join(df.columns)
  print(columns)
  values = ', '.join([f"'{value}'" for value in df.values[0]])
  print(values)
  query = f"INSERT INTO okta_log.log ({columns}) VALUES ({values})"
  cursor.execute(query)
  connection.commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This does successfully add a row to the table and I can see subsequent rows also getting added after running this function each time. But when I reload the table and run the select * again I don't see my rows of data. It seems that the row of data persists only for a short duration and is not permanent&lt;/P&gt;&lt;P&gt;How do I fix this?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 17:05:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/row-insert-into-table-does-not-persist/m-p/51166#M28996</guid>
      <dc:creator>burusam</dc:creator>
      <dc:date>2023-11-13T17:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Row INSERT into table does not persist</title>
      <link>https://community.databricks.com/t5/data-engineering/row-insert-into-table-does-not-persist/m-p/51212#M29007</link>
      <description>&lt;P&gt;HI,&amp;nbsp;&lt;/P&gt;&lt;P&gt;are you closing connection at the end?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;cursor&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;close&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt;
&lt;SPAN class=""&gt;connection&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;close&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Also, can you elaborate what you mean by saying "&lt;SPAN&gt;when I reload the table"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 21:01:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/row-insert-into-table-does-not-persist/m-p/51212#M29007</guid>
      <dc:creator>Emil_Kaminski</dc:creator>
      <dc:date>2023-11-13T21:01:04Z</dc:date>
    </item>
  </channel>
</rss>

