{"id":27,"date":"2025-07-27T00:33:48","date_gmt":"2025-07-26T15:33:48","guid":{"rendered":"https:\/\/wiki.tomori-tech.com\/?p=27"},"modified":"2025-07-27T00:36:15","modified_gmt":"2025-07-26T15:36:15","slug":"markdown%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/wiki.tomori-tech.com\/?p=27","title":{"rendered":"01_Databricks\u6d4b\u8bd5"},"content":{"rendered":"<style>\n\/* \u4ec5\u5bf9\u672c\u6587\u6709\u6548 *\/\npre, code, .highlight {\n    border: none !important;\n}\npre::before, pre::after {\n    display: none !important;\n}\n<\/style>\n<pre><code class=\"language-python line-numbers\">import oracledb\n\ntry:\n    dsn = f\"{host}:{port}\/{service_name}\"\n    connection = oracledb.connect(user=username, password=password, dsn=dsn)\n    cursor = connection.cursor()\n\n    file_id = 1\n    cursor.execute(\"SELECT FILE_DATA FROM C##TMT.FILE_STORAGE WHERE file_id = :1\", [file_id])\n    result = cursor.fetchone()\n\n    if result:\n        file_data = result[0]\n        with open(\"D:\\workspace\\GitHub\\Databricks2.7z\", \"wb\") as f:\n            f.write(file_data.read())\n        print(f\"\u6587\u4ef6ID {file_id} \u4e0b\u8f7d\u6210\u529f\")\n    else:\n        print(f\"\u672a\u627e\u5230\u6587\u4ef6ID {file_id}\")\n\n    print(\"\\n\" + \"=\"*50)\n\nexcept Exception as e:\n    print(f\"\u9519\u8bef: {e}\")\n\nfinally:\n    if 'cursor' in locals():\n        cursor.close()\n    if 'connection' in locals():\n        connection.close()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>import oracledb try: dsn <\/p>\n<\/div>","protected":false},"author":1,"featured_media":82,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databricks"],"views":65,"_links":{"self":[{"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":6,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions\/83"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=\/wp\/v2\/media\/82"}],"wp:attachment":[{"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.tomori-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}