Skip to content

Commit 1abc7d0

Browse files
Clean up dump.py
- consolidate construction of sqlite_sequence - use existing quoting style
1 parent 64f4101 commit 1abc7d0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Lib/sqlite3/dump.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ def _iterdump(connection):
3030
schema_res = cu.execute(q)
3131
sqlite_sequence = []
3232
for table_name, type, sql in schema_res.fetchall():
33-
if table_name == "sqlite_sequence":
34-
sqlite_sequence = ["DELETE FROM \"sqlite_sequence\""]
35-
rows = cu.execute("SELECT * FROM \"sqlite_sequence\";").fetchall()
36-
sqlite_sequence.extend(["INSERT INTO \"sqlite_sequence\" VALUES('{0}',{1})"
37-
.format(row[0], row[1]) for row in rows])
38-
continue
33+
if table_name == 'sqlite_sequence':
34+
rows = cu.execute('SELECT * FROM "sqlite_sequence";').fetchall()
35+
sqlite_sequence = ['DELETE FROM "sqlite_sequence"']
36+
sqlite_sequence += [
37+
f'INSERT INTO "sqlite_sequence" VALUES(\'{row[0]}\',{row[1]})'
38+
for row in rows
39+
]
3940
elif table_name == 'sqlite_stat1':
4041
yield('ANALYZE "sqlite_master";')
4142
elif table_name.startswith('sqlite_'):
@@ -72,8 +73,9 @@ def _iterdump(connection):
7273
for name, type, sql in schema_res.fetchall():
7374
yield('{0};'.format(sql))
7475

75-
# Yield statements concerning the sqlite_sequence table at the end of the transaction: (bpo-34828)
76+
# gh-79009: Yield statements concerning the sqlite_sequence table at the
77+
# end of the transaction.
7678
for row in sqlite_sequence:
77-
yield("{0};".format(row))
79+
yield('{0};'.format(row))
7880

7981
yield('COMMIT;')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy