{"id":2746,"date":"2019-08-08T12:38:35","date_gmt":"2019-08-08T10:38:35","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=2746"},"modified":"2019-09-04T06:28:10","modified_gmt":"2019-09-04T04:28:10","slug":"sqlite3-tkinter-part-ii","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/sqlite3-tkinter-part-ii\/","title":{"rendered":"Sqlite3 &#038; Tkinter &#8211; Part II"},"content":{"rendered":"<p>After some days from the <a href=\"https:\/\/pythonprogramming.altervista.org\/python-and-sqlite-with-tkinter-part-1\/\">first post about <strong>sqlite<\/strong><\/a>, we are back at the code writing to finish the app we wanted to. <strong>Tkinter<\/strong> is one of the topic that I often write about in this blog, as you could be aware of searching into my posts, and I always try to write about it&#8217;s features making practical <strong>examples<\/strong>, rather than talking in abstract of his widgets and stuffs. This three tools together can do a lot of good things, I think. Let&#8217; go into more details about it through a little app to create <strong>databases<\/strong> with <strong>sqlite3<\/strong>.<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/pysqltk.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2630 aligncenter\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/pysqltk.png\" alt=\"\" width=\"411\" height=\"138\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/pysqltk.png 641w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/pysqltk-320x107.png 320w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/a><\/p>\n<p>This second post about our little application to use sqlite3 database with python and tkinter. The tkinter module is a built-in one of python that allows us to create graphic user interfaces. We want to create this GUI to:<\/p>\n<ul>\n<li>create a sqlite database<\/li>\n<li>create a table<\/li>\n<li>insert data in the table<\/li>\n<li>do other stuffs<\/li>\n<\/ul>\n<p>In the <a href=\"https:\/\/pythonprogramming.altervista.org\/python-and-sqlite-with-tkinter-part-1\/\">first post and video(python and sqlite with tkinter)<\/a> (go <a href=\"https:\/\/pythonprogramming.altervista.org\/python-and-sqlite-with-tkinter-part-1\/\">here<\/a> to read and watch if you do not have done it yet) we created a window to generate databases with nothing inside.<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/sql1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2748 aligncenter\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/sql1.jpg\" alt=\"\" width=\"204\" height=\"285\" \/><\/a><\/p>\n<p>This is how the windows appeared. It does what it looks like it does.<\/p>\n<h2>Create tables with sqlite and tkinter<\/h2>\n<p>Now we will add tables through the interface. Before we start we will include the function create into the class to create the window called Win.<\/p>\n<p>Let&#8217;s do this (the most relevant part of this code is\u00a0<strong>conn = lite.connect(db)<\/strong> that opens \/ creates the database.<\/p>\n<pre class=\"lang:default decode:true\">def create(obj):\r\n\tdb = obj.e.get()\r\n\tif db[-3] == \".db\":\r\n\t\tpass\r\n\telse:\r\n\t\tdb = db + \".db\"\r\n\ttry:\r\n\t\tconn = lite.connect(db)\r\n\t\treturn conn\r\n\texcept Error as e:\r\n\t\tprint(e)\r\n\tfinally:\r\n\t\tconn.close()\r\n\t\tobj.lb.insert(tk.END, db)\r\n\t\tobj.db.set(\"\")<\/pre>\n<p>The function above will be in included in the <strong>Win class<\/strong> (that we will call now App). The function will be a method of App and we will change the name from create to <strong>mk_db<\/strong>. Instead of &#8216;obj&#8217; we will put self as it&#8217;s in the class. There are other changes explained in the video.<\/p>\n<pre class=\"lang:default decode:true \">\tdef mk_db(self):\r\n\t\tdb = self.e.get()\r\n\t\tif db.endswith(\".db\"):\r\n\t\t\tpass\r\n\t\telse:\r\n\t\t\tdb = db + \".db\"\r\n\t\ttry:\r\n\t\t\tconn = lite.connect(db)\r\n\t\t\tself.lb.insert(tk.END, db)\r\n\t\t\tself.e_string_var.set(\"\")\r\n\t\t\treturn conn\r\n\t\texcept Error as e:\r\n\t\t\tprint(e)\r\n\t\tfinally:\r\n\t\t\tconn.close()<\/pre>\n<p>This are other changes, consequential to the decisions we took previously:<\/p>\n<p>We change the name of &#8216;db&#8217; (StringVar object) in &#8216;e_string_var&#8217;, for more intuitive stuff:<\/p>\n<pre class=\"lang:default decode:true \">\t\tself.e_string_var = tk.StringVar()\r\n\t\tself.e = tk.Entry(self.root, textvariable=self.e_string_var)\r\n\t\tself.e.pack()<\/pre>\n<p>and also the button need some changes:<\/p>\n<pre class=\"lang:default decode:true \">\t\tself.b = tk.Button(self.root, text=\"Create DB\", command= lambda: self.mk_db())\r\n\t\tself.b.pack()<\/pre>\n<p>So, nothing dramatic until know. We just moved some lines of code into the main class and changed some names.<\/p>\n<p>There is a last thing. We put the creation of the Tk() object outside of the App, for reason that will be declared later. This is the complete code at the end.<\/p>\n<pre class=\"lang:default decode:true\">import sqlite3 as lite\r\nfrom sqlite3 import Error\r\nimport tkinter as tk\r\nfrom glob import glob\r\n\r\n\r\n\r\nclass App:\r\n\t# window\r\n\tdef __init__(self, root):\r\n\t\tself.root = root\r\n\t\t# entry containing the db name\r\n\t\t\r\n\t\tself.l = tk.Label(self.root, text=\"Create a db [insert the name]\")\r\n\t\tself.l.pack()\r\n\r\n\t\tself.e_string_var = tk.StringVar()\r\n\t\tself.e = tk.Entry(self.root, textvariable=self.e_string_var)\r\n\t\tself.e.pack()\r\n\r\n\t\tself.b = tk.Button(self.root, text=\"Create DB\", command= lambda: self.mk_db())\r\n\t\tself.b.pack()\r\n\r\n\t\tself.lb = tk.Listbox(self.root)\r\n\t\tself.lb.pack()\r\n\t\tself.show_db()\r\n\r\n\tdef mk_db(self):\r\n\t\tdb = self.e.get()\r\n\t\tif db.endswith(\".db\"):\r\n\t\t\tpass\r\n\t\telse:\r\n\t\t\tdb = db + \".db\"\r\n\t\ttry:\r\n\t\t\tconn = lite.connect(db)\r\n\t\t\tself.lb.insert(tk.END, db)\r\n\t\t\tself.e_string_var.set(\"\")\r\n\t\t\treturn conn\r\n\t\texcept Error as e:\r\n\t\t\tprint(e)\r\n\t\tfinally:\r\n\t\t\tconn.close()\r\n\r\n\r\n\tdef show_db(self):\r\n\t\tfor file in glob(\"*.db\"):\r\n\t\t\tself.lb.insert(tk.END, file)\r\n\r\n\t\t\r\n\r\nroot = tk.Tk()\r\napp = App(root)\r\nroot.mainloop()<\/pre>\n<p>Functionality are the same. Nothing changed. Time to create tables.<\/p>\n<h2>The mk_tb method to create tables, finally<\/h2>\n<p>To create the fields we use this<\/p>\n<pre class=\"lang:default decode:true \">\tdef mk_fl(self):\r\n\t\tself.fields.append(self.efl.get())\r\n\t\tself.vfl.set(\"\")<\/pre>\n<p>The fields will go into a list called self.fields. In the mk_tb method to create the table, this fields list will become a string.<\/p>\n<p>Here is the function for the table<\/p>\n<pre class=\"lang:default decode:true \">\tdef mk_tb(self, dbn, tbn):\r\n\t\tself.conn = lite.connect(dbn.get())\r\n\t\tself.cur = self.conn.cursor()\r\n\t\tself.fields = \"\".join(self.fields)\r\n\t\tself.cur.execute(\"\"\"create table {} (\r\n\t\t{});\"\"\".format(tbn, self.fields))\r\n\t\tself.fields = []\r\n\t\tself.conn.close()<\/pre>\n<p>Simple:<\/p>\n<ul>\n<li>open the database<\/li>\n<li>start the cursor()<\/li>\n<li>join the list of fields in a string<\/li>\n<li>execute the string with the sql command<\/li>\n<li>close the database<\/li>\n<\/ul>\n<p>When this function is called there are two arguments:<\/p>\n<ul>\n<li>the name of the database (to open it with lite.connect(dbn)<\/li>\n<li>the name of the table (that will go in the string with the commands<\/li>\n<\/ul>\n<p>The fields will be taken from the attribute self.fields, that was a list, transformed in string with join. We don&#8217;t need to pass them.<\/p>\n<h2>The widgets<\/h2>\n<p>Now we just need the widgets to insert the name of the database, of the table and to define the fields.<\/p>\n<p>The fields have a label (name) and then the type of fields (text or integer, float etc) and must be followed by a comma (we could add some code to avoid forgetting it).<\/p>\n<h2>The label and Entry for the db name<\/h2>\n<pre class=\"lang:default decode:true \">\t\t# label and Entry for Database name\r\n\t\tself.ldbname = tk.Label(self.root, text=\"Insert Database name\")\r\n\t\tself.ldbname.pack()\r\n\t\tself.dbn = tk.StringVar()\r\n\t\tself.edb = tk.Entry(self.root, textvariable = self.dbn)\r\n\t\tself.edb.pack()<\/pre>\n<h2>The label and Entry for the table name<\/h2>\n<pre class=\"lang:default decode:true \">\t\tself.ltbname = tk.Label(self.root, text=\"Insert Table name\")\r\n\t\tself.ltbname.pack()\r\n\t\tself.tbn = tk.StringVar()\r\n\t\tself.etb = tk.Entry(self.root, textvariable = self.tbn)\r\n\t\tself.etb.pack()<\/pre>\n<h2>The label, the entry and the butto for the fields<\/h2>\n<p>You create a fields like<\/p>\n<p>name text,<\/p>\n<p>and then click the button &#8220;Create fields&#8221;&#8230;<\/p>\n<p>Repeat for all the fields.<\/p>\n<pre class=\"lang:default decode:true\">\t\t# FIELDS - vfl is the StringVar, efl is the Entry\r\n\t\tself.lflname = tk.Label(self.root, text=\"Insert Fields name and type\\n followeb by a comma, one by one,\\nclicking once for each field.\")\r\n\t\tself.lflname.pack()\r\n\t\tself.vfl = tk.StringVar()\r\n\t\tself.efl = tk.Entry(self.root, textvariable = self.vfl)\r\n\t\tself.efl.pack()\r\n\t\tself.bfl = tk.Button(self.root, text=\"Create Field\", command= lambda: self.mk_fl())\r\n\t\tself.bfl.pack()<\/pre>\n<p>&nbsp;<\/p>\n<p>When you have finished inserting the fields, you click &#8220;Create the table&#8221;.<\/p>\n<h2>The button to create the table<\/h2>\n<pre class=\"lang:default decode:true\">\t\tself.btb = tk.Button(self.root, text=\"Create Table\", command= lambda: self.mk_tb(self.dbn, self.tbn))\r\n\t\tself.btb.pack()<\/pre>\n<p><iframe loading=\"lazy\" title=\"Sqlite and tkinter, part 2: create table\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/p15F59Tgaz8?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>The whole code until creation of the tables<\/h2>\n<pre class=\"lang:default decode:true\">import sqlite3 as lite\r\nfrom sqlite3 import Error\r\nimport tkinter as tk\r\nfrom glob import glob\r\n\r\n\r\n\r\nclass App:\r\n\t# window\r\n\tdef __init__(self, root):\r\n\r\n\t\tself.fields = []\r\n\r\n\r\n\t\tself.root = root\r\n\t\t# entry containing the db name\r\n\t\t\r\n\t\tself.l = tk.Label(self.root, text=\"Create a db [insert the name]\")\r\n\t\tself.l.pack()\r\n\r\n\t\tself.db = tk.StringVar()\r\n\t\tself.e = tk.Entry(self.root, textvariable=self.db)\r\n\t\tself.e.pack()\r\n\r\n\t\tself.b = tk.Button(self.root, text=\"Create DB\", command= lambda: self.mk_db())\r\n\t\tself.b.pack()\r\n\r\n\t\tself.lb = tk.Listbox(self.root)\r\n\t\tself.lb.pack()\r\n\t\tself.show_db()\r\n\r\n\t\t# label and Entry for Database name\r\n\t\tself.ldbname = tk.Label(self.root, text=\"Insert Database name\")\r\n\t\tself.ldbname.pack()\r\n\t\tself.dbn = tk.StringVar()\r\n\t\tself.edb = tk.Entry(self.root, textvariable = self.dbn)\r\n\t\tself.edb.pack()\r\n \r\n\t\tself.ltbname = tk.Label(self.root, text=\"Insert Table name\")\r\n\t\tself.ltbname.pack()\r\n\t\tself.tbn = tk.StringVar()\r\n\t\tself.etb = tk.Entry(self.root, textvariable = self.tbn)\r\n\t\tself.etb.pack()\r\n\r\n\t\t# FIELDS - vfl is the StringVar, efl is the Entry\r\n\t\tself.lflname = tk.Label(self.root, text=\"Insert Fields name and type\\n followeb by a comma, one by one,\\nclicking once for each field.\")\r\n\t\tself.lflname.pack()\r\n\t\tself.vfl = tk.StringVar()\r\n\t\tself.efl = tk.Entry(self.root, textvariable = self.vfl)\r\n\t\tself.efl.pack()\r\n\t\tself.bfl = tk.Button(self.root, text=\"Create Field\", command= lambda: self.mk_fl())\r\n\t\tself.bfl.pack()\r\n\r\n\t\tself.btb = tk.Button(self.root, text=\"Create Table\", command= lambda: self.mk_tb(self.dbn, self.tbn))\r\n\t\tself.btb.pack()\r\n\r\n\r\n\tdef show_db(self):\r\n\t\tfor file in glob(\"*.db\"):\r\n\t\t\tself.lb.insert(tk.END, file)\r\n\r\n\tdef mk_db(self):\r\n\t\tdb = self.e.get()\r\n\t\tif db.endswith(\".db\"):\r\n\t\t\tpass\r\n\t\telse:\r\n\t\t\tdb = db + \".db\"\r\n\t\ttry:\r\n\t\t\tconn = lite.connect(db)\r\n\t\t\tif db in self.lb.get(0, tk.END):\r\n\t\t\t\tpass\r\n\t\t\telse:\r\n\t\t\t\tself.lb.insert(tk.END, db)\r\n\t\t\treturn conn\r\n\t\texcept Error as e:\r\n\t\t\tprint(e)\r\n\t\tfinally:\r\n\t\t\tself.db.set(\"\")\r\n\t\t\tconn.close()\r\n\r\n\tdef mk_tb(self, dbn, tbn):\r\n\t\tself.conn = lite.connect(dbn.get())\r\n\t\tself.cur = self.conn.cursor()\r\n\t\tself.fields = \"\".join(self.fields)\r\n\t\tself.cur.execute(\"\"\"create table {} (\r\n\t\t{});\"\"\".format(tbn, self.fields))\r\n\t\tself.fields = []\r\n\t\tself.conn.close()\r\n\r\n\r\n\tdef mk_fl(self):\r\n\t\tself.fields.append(self.efl.get())\r\n\t\tself.vfl.set(\"\")\r\n\r\n\r\n\r\nroot = tk.Tk()\t\r\nwin = App(root)\r\nroot.mainloop()<\/pre>\n<h2>The window<\/h2>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/sql2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2756 aligncenter\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/08\/sql2.jpg\" alt=\"\" width=\"270\" height=\"434\" \/><\/a><\/p>\n<h2>Some restyiling to the code<\/h2>\n<p>Nothing is changed in this code from above, apart some methods to add readability.<\/p>\n<pre class=\"lang:default decode:true  \">import sqlite3 as lite\r\nfrom sqlite3 import Error\r\nimport tkinter as tk\r\nfrom glob import glob\r\n\r\n\r\n\r\nclass App:\r\n    # window\r\n    def __init__(self, root):\r\n\r\n        self.fields = []\r\n        self.root = root\r\n        self.label()\r\n        self.entry()\r\n        self.button()\r\n        self.listbox()\r\n        self.db_name_widgets()\r\n        self.tb_name_widgets()\r\n        self.fields_widgets()\r\n        self.btn_create_table()\r\n\r\n    def label(self):\r\n        self.l = tk.Label(self.root, text=\"Create a db [insert the name]\")\r\n        self.l.pack()\r\n\r\n    def entry(self):\r\n        self.db = tk.StringVar()\r\n        self.e = tk.Entry(self.root, textvariable=self.db)\r\n        self.e.pack()\r\n\r\n    def button(self):\r\n        self.b = tk.Button(self.root, text=\"Create DB\", command= lambda: self.mk_db())\r\n        self.b.pack()\r\n\r\n    def listbox(self):\r\n        self.lb = tk.Listbox(self.root)\r\n        self.lb.pack()\r\n        self.show_db()\r\n\r\n    def db_name_widgets(self):\r\n        # label and Entry for Database name\r\n        self.ldbname = tk.Label(self.root, text=\"Insert Database name\")\r\n        self.ldbname.pack()\r\n        self.dbn = tk.StringVar()\r\n        self.edb = tk.Entry(self.root, textvariable = self.dbn)\r\n        self.edb.pack()\r\n\r\n    def tb_name_widgets(self):\r\n        self.ltbname = tk.Label(self.root, text=\"Insert Table name\")\r\n        self.ltbname.pack()\r\n        self.tbn = tk.StringVar()\r\n        self.etb = tk.Entry(self.root, textvariable = self.tbn)\r\n        self.etb.pack()\r\n\r\n    def fields_widgets(self):\r\n        self.lflname = tk.Label(self.root, text=\"Insert Fields name and type\\n followeb by a comma, one by one,\\nclicking once for each field.\")\r\n        self.lflname.pack()\r\n        self.vfl = tk.StringVar()\r\n        self.efl = tk.Entry(self.root, textvariable = self.vfl)\r\n        self.efl.pack()\r\n        self.bfl = tk.Button(self.root, text=\"Create Field\", command= lambda: self.mk_fl())\r\n        self.bfl.pack()\r\n\r\n    def btn_create_table(self):\r\n        self.btb = tk.Button(self.root, text=\"Create Table\", command= lambda: self.mk_tb(self.dbn, self.tbn))\r\n        self.btb.pack()\r\n\r\n    def show_db(self):\r\n        for file in glob(\"*.db\"):\r\n            self.lb.insert(tk.END, file)\r\n\r\n    def mk_db(self):\r\n        db = self.e.get()\r\n        if db.endswith(\".db\"):\r\n            pass\r\n        else:\r\n            db = db + \".db\"\r\n        try:\r\n            conn = lite.connect(db)\r\n            if db in self.lb.get(0, tk.END):\r\n                pass\r\n            else:\r\n                self.lb.insert(tk.END, db)\r\n            return conn\r\n        except Error as e:\r\n            print(e)\r\n        finally:\r\n            self.db.set(\"\")\r\n            conn.close()\r\n\r\n    def mk_tb(self, dbn, tbn):\r\n        self.conn = lite.connect(dbn.get())\r\n        self.cur = self.conn.cursor()\r\n        self.fields = \"\".join(self.fields)\r\n        self.cur.execute(\"\"\"create table {} (\r\n        {});\"\"\".format(tbn, self.fields))\r\n        self.fields = []\r\n        self.conn.close()\r\n\r\n    def mk_fl(self):\r\n        self.fields.append(self.efl.get())\r\n        self.vfl.set(\"\")\r\n\r\n\r\n\r\nroot = tk.Tk()  \r\nwin = App(root)\r\nroot.mainloop()<\/pre>\n<p>&nbsp;<\/p>\n<script>\r\nlet title = \"SqLite3 & Python\"\r\n\tlet links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-and-sqlite-basics\/\",\"Sqlite3 Basic 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-and-sqlite-with-tkinter-part-1\/\",\"Sqlite3 - part 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/sqlite3-tkinter-part-ii\/\",\"Sqlite3 - part 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-sqlite3-part-3-reoganizing-the-code\/\",\"Sqlite3 - part 3.1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/sqlite-and-python-part-3-2\/\",\"Sqlite3 - part 3.2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/sqlite-and-tkinter-in-python-part-3-3\/\",\"Sqlite3 - part 3.3\"]\r\n\t];\r\n<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"Try some code with tkinter and sqlite to see how you could create a GUI for a database with these tools united with the power and the elgance of Python.\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/sqlite3-tkinter-part-ii\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":2755,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[479,1,480,481],"tags":[74,239,119,73,4,499,485,320,51],"class_list":["post-2746","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-examples","category-sqlite","category-sqlite3","tag-button","tag-database","tag-entry","tag-label","tag-python","tag-sql","tag-sqlite3","tag-table","tag-tkinter"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=2746"}],"version-history":[{"count":14,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2746\/revisions"}],"predecessor-version":[{"id":2759,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2746\/revisions\/2759"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/2755"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=2746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=2746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=2746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}