omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Haspario

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 1
    • Controversial 0
    • Groups 0

    Haspario

    @Haspario

    1
    Reputation
    437
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Haspario Unfollow Follow

    Best posts made by Haspario

    • RE: SQLite3

      I am new to python but have worked out where I was going wrong. I thought I needed to make a connection to a specific file path.

      Here's my (very) basic database code, still only just getting my head around it!

      <pre>
      import sqlite3

      conn = sqlite3.connect("mydatabase.db")

      cursor = conn.cursor()

      conn.execute("""DROP TABLE IF EXISTS alicelist""")

      cursor.execute("""CREATE TABLE alicelist
      (name text, character text, scenes text)
      """)

      alicelist = [('Kate Threlfall', 'Alice', '10'),
      ('Ailsa', 'Mother/White Queen', '5'),
      ('Chloe Harley', 'Sister/Red Queen','5'),
      ('Olivia Pewsey', 'Tweedle Dum', '4'),
      ('Anna Winstanley', 'Tweedle Dee', '4')]
      cursor.executemany("INSERT INTO alicelist VALUES (?,?,?)", alicelist)
      conn.commit()

      print "\nHere's a listing of all the records in the table:\n"
      for row in cursor.execute("SELECT rowid, * FROM alicelist ORDER BY character"):
      print row

      print cursor.fetchall()
      </pre>

      posted in Pythonista
      Haspario
      Haspario

    Latest posts made by Haspario

    • SQLite3

      Can this be used in pythonista to create a database with file access? I have only had success making a connection to memory if that makes sense!

      posted in Pythonista
      Haspario
      Haspario
    • RE: SQLite3

      P.s. Pythonista is a fantastic resource and really helping me get to grips with python. Many thanks

      posted in Pythonista
      Haspario
      Haspario
    • RE: SQLite3

      I am new to python but have worked out where I was going wrong. I thought I needed to make a connection to a specific file path.

      Here's my (very) basic database code, still only just getting my head around it!

      <pre>
      import sqlite3

      conn = sqlite3.connect("mydatabase.db")

      cursor = conn.cursor()

      conn.execute("""DROP TABLE IF EXISTS alicelist""")

      cursor.execute("""CREATE TABLE alicelist
      (name text, character text, scenes text)
      """)

      alicelist = [('Kate Threlfall', 'Alice', '10'),
      ('Ailsa', 'Mother/White Queen', '5'),
      ('Chloe Harley', 'Sister/Red Queen','5'),
      ('Olivia Pewsey', 'Tweedle Dum', '4'),
      ('Anna Winstanley', 'Tweedle Dee', '4')]
      cursor.executemany("INSERT INTO alicelist VALUES (?,?,?)", alicelist)
      conn.commit()

      print "\nHere's a listing of all the records in the table:\n"
      for row in cursor.execute("SELECT rowid, * FROM alicelist ORDER BY character"):
      print row

      print cursor.fetchall()
      </pre>

      posted in Pythonista
      Haspario
      Haspario