-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjyjdbc.py
More file actions
55 lines (39 loc) · 1.09 KB
/
jyjdbc.py
File metadata and controls
55 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from com.ziclix.python.sql import zxJDBC
# Modify as needed for your database.
url='jdbc:hsqldb:hsql://localhost/xdb'
user='sa'
pw=''
driver='org.hsqldb.jdbcDriver'
db = zxJDBC.connect(url, user, pw, driver)
cursor = db.cursor()
cursor.execute("""
create table user
(userid integer,
username varchar,
firstname varchar,
lastname varchar,
phone varchar)
""")
cursor.execute("""create index userid on user (userid)""")
cursor.execute("""
insert into user (userid,username,firstname,lastname,phone)
values (1,'ericfj','Eric','Foster-Johnson','555-5555')
""")
cursor.execute("""
insert into user (userid,username,firstname,lastname,phone)
values (2,'tosh','Peter','Tosh','555-5554')
""")
cursor.execute("""
insert into user (userid,username,firstname,lastname,phone)
values (3,'bob','Bob','Marley','555-5553')
""")
cursor.execute("""
insert into user (userid,username,firstname,lastname,phone)
values (4,'scientist','Hopeton','Brown','555-5552')
""")
db.commit()
cursor.execute("select * from user")
for row in cursor.fetchall():
print(row)
cursor.close()
db.close()