| Trees | Indices | Help |
|---|
|
|
1 # Copyright 2002 by Andrew Dalke. All rights reserved.
2 # Revisions 2007-2008 by Peter Cock.
3 # This code is part of the Biopython distribution and governed by its
4 # license. Please see the LICENSE file that should have been included
5 # as part of this package.
6 #
7 # Note that BioSQL (including the database schema and scripts) is
8 # available and licensed separately. Please consult www.biosql.org
9
10 _dbutils = {}
11
15
19
20 # Disabled: better safe than sorry
21 ## def next_id(self, cursor, table):
22 ## # XXX brain-dead! Hopefully, the database will enforce PK unicity..
23 ## table = self.tname(table)
24 ## sql = r"select 1+max(%s_id) from %s" % (table, table)
25 ## cursor.execute(sql)
26 ## rv = cursor.fetchone()
27 ## return rv[0]
28
30 # XXX: Unsafe without transactions isolation
31 table = self.tname(table)
32 sql = r"select max(%s_id) from %s" % (table, table)
33 cursor.execute(sql)
34 rv = cursor.fetchone()
35 return rv[0]
36
40
51
52 _dbutils["MySQLdb"] = Mysql_dbutils
53
56 table = self.tname(table)
57 sql = r"select nextval('%s_pk_seq')" % table
58 cursor.execute(sql)
59 rv = cursor.fetchone()
60 return rv[0]
61
63 table = self.tname(table)
64 sql = r"select currval('%s_pk_seq')" % table
65 cursor.execute(sql)
66 rv = cursor.fetchone()
67 return rv[0]
68
70 conn.autocommit(y)
71 _dbutils["psycopg"] = Psycopg_dbutils
72
74 """Add support for pgdb in the PyGreSQL database connectivity package.
75 """
77 table = self.tname(table)
78 sql = r"select nextval('%s_pk_seq')" % table
79 cursor.execute(sql)
80 rv = cursor.fetchone()
81 return rv[0]
82
84 table = self.tname(table)
85 sql = r"select currval('%s_pk_seq')" % table
86 cursor.execute(sql)
87 rv = cursor.fetchone()
88 return rv[0]
89
92
93 _dbutils["pgdb"] = Pgdb_dbutils
94
100
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Mon Sep 15 09:22:49 2008 | http://epydoc.sourceforge.net |