How can you use SQL queries on pydroid app?

Created at 12-Jan-2021 , By samar

How can you use SQL queries on pydroid app?

Through many examples, we will learn how to resolve the "How can you use SQL queries on pydroid app?".

  • # This code demonstrates a SQLite connection on Android.
    # You can use it in the Code Playground or another app like Pydroid3.
    import sqlite3
    conn = sqlite3.connect('pythonexample.db')
    # If running in Pydroid, the above will save to the Pydroid directory on your device
    # You could also specify a folder on your device if you have permission to save there. For example:
    # conn = sqlite3.connect('/storage/emulated/0/Download/pythonexample.db')
    # Change the above to whatever your download folder is on your device. You'll usually have permission to write there on Android.
    c = conn.cursor()
    # Create a table
    c.execute('''CREATE TABLE trainingclass
                 (sitename text, classname text, classrating text, userscore real)''')
    # Insert a row of sample data
    c.execute("INSERT INTO trainingclass VALUES ('Sololearn','Python','5 Stars',70.12)")
    # Save the changes
    t = ('Python',)
    c.execute('SELECT * FROM trainingclass WHERE classname=?', t)
    # Close the connection
    # After running this code, I was able to open the database from a SQLite client on Android.
    After creating the database in Python, I was able to open it and view the data in a SQLite client on Android.

Back to code snippet queries related python

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.