We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48d38a9 commit 3abc0aeCopy full SHA for 3abc0ae
2 files changed
employees.db
2 KB
python_sqlite.py
@@ -0,0 +1,30 @@
1
+import sqlite3
2
+
3
4
+# Creating a connection sqlite database, it will create .db file in file system
5
+# other way to create is using memory, so database will be in memory (RAM)
6
+# conn = sqlite3.connect(':memory:')
7
+conn = sqlite3.connect('employees.db')
8
9
+# To get cursor to the database
10
+c = conn.cursor()
11
12
+# Create table using cursor
13
+#c.execute("""CREATE TABLE employees
14
+# (
15
+# first test,
16
+# last text,
17
+# pay integer
18
+# )""")
19
20
+#c.execute("""INSERT INTO employees VALUES ('sheldon', 'cooper', '50000')""")
21
22
+c.execute("SELECT * FROM employees WHERE last='cooper'")
23
24
+print(c.fetchone())
25
26
+# Always use conn.commit after execute statement
27
+conn.commit()
28
29
+# always good to close a connection
30
+conn.close()
0 commit comments