omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    name ‘date_login’ not defined....

    Pythonista
    name not define
    4
    13
    4662
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp @sendog3c last edited by cvp

      @sendog3c The code crashs for "name date_login is not defined".
      And obviously, you have not defined the variables to be written in your db.
      Then do this to get data you entered

              date_login = '20190101' # or what you want
              user_name = sender.superview['t1'].text
              pwd_user  = sender.superview['t2'].text
      

      and this to give a name to the TextFields where you enter data

      t1=ui.TextField(frame=(50,100,300,40),name='t1')
      t2=ui.TextField(frame=(50,200,300,40),name='t2')
      
      1 Reply Last reply Reply Quote 0
      • cvp
        cvp @JonB last edited by

        @JonB said:

        Also, note in one case you are trying to execute with variable names, but in the other case you use literals.

        That is normal:
        In the create statement, the variables names are littéral
        In the insert statement, the variables names are variables

        1 Reply Last reply Reply Quote 0
        • sendog3c
          sendog3c last edited by

          Thank you both.

          Where can I manipulate sqlite3. I mean, Browse data, delete columns, etc.

          Regards;

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @sendog3c last edited by cvp

            @sendog3c said:

            Where can I manipulate sqlite3

            Do you want to say "where can I find how to..."?
            If this is the question, there are a lot of docs, like this one

            Example (be careful, your conn.close needs parentheses)

            def button2_tapped(sender):
                    date_login = '20190101' # or what you want
                    user_name = sender.superview['t1'].text
                    pwd_user  = sender.superview['t2'].text
                    c.execute("INSERT INTO logindata VALUES(?,?,?)", (date_login, user_name, pwd_user))
                    conn.commit()
                    c.execute("SELECT * FROM logindata")
                    rows = c.fetchall()
                    print(rows)
                    conn.close()
            
            1 Reply Last reply Reply Quote 0
            • sendog3c
              sendog3c last edited by

              Yes I know there a lot docs here, but I mean if there is by example: a console to work with my DB alone or if there is way to use command line with specific sqilte3's instructions. supposing "sqlte3 /?".

              Thanks.

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @sendog3c last edited by

                @sendog3c you could write a little script like

                import console
                import sqlite3
                
                conn = sqlite3.connect("logindata.db", check_same_thread=False)
                c = conn.cursor()
                #c.execute("CREATE TABLE IF NOT EXISTS logindata (date_login, user_name, pwd_user)")
                
                while True:
                	r = input()
                	if r == 'close':
                		break
                	#PRAGMA table_info(logindata)
                	#SELECT * FROM logindata
                	c.execute(r)
                	rows = c.fetchall()
                	print(rows)
                	
                c.close()
                

                It will ask you a sql command, execute it, fetch the results and print them
                Try with
                PRAGMA table_info(logindata)
                Or
                SELECT * FROM logindata

                Of course, this is only valid for commands which can be followed by a fetch.
                Up to you to modify the code to make it more generalized

                1 Reply Last reply Reply Quote 1
                • sendog3c
                  sendog3c last edited by

                  Thanks again

                  1 Reply Last reply Reply Quote 0
                  • brumm
                    brumm last edited by

                    I bought the SQLed app for quick checking things. The downside is you have to "share..." the sqlite db between the apps.

                    Btw. in the PythonCheatSheet is a sqlite section.

                    1 Reply Last reply Reply Quote 0
                    • sendog3c
                      sendog3c last edited by

                      Thank you Brumm. I a going to check it.

                      1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB last edited by

                        I haven't tried it, but there is https://forum.omz-software.com/topic/2326/sqlite3-browser

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors