{"id":4425,"date":"2023-11-24T14:56:17","date_gmt":"2023-11-24T14:56:17","guid":{"rendered":"https:\/\/ibex.tech\/python\/?p=4425"},"modified":"2025-01-22T10:53:19","modified_gmt":"2025-01-22T10:53:19","slug":"open-database","status":"publish","type":"post","link":"https:\/\/ibex.tech\/python\/database\/sqlite\/database-sqlite\/open-database","title":{"rendered":"Open database"},"content":{"rendered":"\n<p>Example create\/open a database and return it ready to be used<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import sqlite3\n\ndb1 = None\ndb1cursor = None\n\ndef open_my_database():\n\n    global db1\n    global db1cursor\n\n    #Open the database (will be created if not already present)\n    db1 = sqlite3.connect(C:\\\\MyFolderName\\\\MyDatabaseName.db')\n    db1cursor = db1.cursor()        #Get the cursor object to access the database\n\n    return<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Closing database connection<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>    #Close the database\n    db1.close()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example create\/open a database and return it ready to be used Closing database connection<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[352],"tags":[],"class_list":["post-4425","post","type-post","status-publish","format-standard","hentry","category-database-sqlite"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/comments?post=4425"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4425\/revisions"}],"predecessor-version":[{"id":4810,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4425\/revisions\/4810"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/media?parent=4425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/categories?post=4425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/tags?post=4425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}