Created
December 23, 2022 17:10
-
-
Save DanEdens/bc0e08b6ef6ee8adba504094dcf988a7 to your computer and use it in GitHub Desktop.
store_sql_data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
def store_data(device, version, results_url, ticket_key, timestamp, test_name, test_config): | |
conn = sqlite3.connect('tests.db') | |
c = conn.cursor() | |
c.execute('CREATE TABLE IF NOT EXISTS tests (device text, version text, results_url text, ticket_key text, timestamp text, test_name text, test_config text)') | |
c.execute('INSERT INTO tests (device, version, results_url, ticket_key, timestamp, test_name, test_config) VALUES (?, ?, ?, ?, ?, ?, ?)', (device, version, results_url, ticket_key, timestamp, test_name, test_config)) | |
conn.commit() | |
conn.close() | |
# This function will create a SQLite database called tests.db if it doesn't already exist, and then create a table called tests if it doesn't exist. The function will then insert the provided data into this table. | |
# You can call this function by passing in the relevant data as arguments, like so: | |
# Copy code | |
# store_data('device1', '1.0', 'http://results.com', 'ABC123', '2022-12-09 12:00:00', 'test1', 'config1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment