Example create/open a database and return it ready to be used

import sqlite3

    #Open the database (will be created if not already present)
    db1 = sqlite3.connect(C:\\MyFolderName\\MyDatabaseName.db')
    db1cursor = db1.cursor()        #Get the cursor object to access the database

    db1cursor.execute("""CREATE TABLE IF NOT EXISTS tblMyTableName (
                        Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                        MyIntigerField INTEGER,
                        MyNumericField NUMERIC,
                        MyRealField REAL,
                        MyTextField TEXT
        )""")
    db1.commit()
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *