Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b9803421
Kaydet (Commit)
b9803421
authored
Mar 28, 2008
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Accept patch issue2426 by Paul Kippes (kippesp).
Adds sqlite3.Connection.iterdump to allow dumping of databases.
üst
621cd262
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
2 deletions
+76
-2
sqlite3.rst
Doc/library/sqlite3.rst
+21
-0
test_sqlite.py
Lib/test/test_sqlite.py
+3
-2
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
connection.c
Modules/_sqlite/connection.c
+48
-0
No files found.
Doc/library/sqlite3.rst
Dosyayı görüntüle @
b9803421
...
...
@@ -378,6 +378,27 @@ A :class:`Connection` instance has the following attributes and methods:
deleted since the database connection was opened.
.. attribute:: Connection.iterdump
Returns an iterator to dump the database in an SQL text format. Useful when
saving an in-memory database for later restoration. This function provides
the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
shell.
.. versionadded:: 2.6
Example::
# Convert file existing_db.db to SQL dump file dump.sql
import sqlite3, os
con = sqlite3.connect('existing_db.db')
full_dump = os.linesep.join([line for line in con.iterdump()])
f = open('dump.sql', 'w')
f.writelines(full_dump)
f.close()
.. _sqlite3-cursor-objects:
Cursor Objects
...
...
Lib/test/test_sqlite.py
Dosyayı görüntüle @
b9803421
...
...
@@ -5,12 +5,13 @@ try:
except
ImportError
:
raise
TestSkipped
(
'no sqlite available'
)
from
sqlite3.test
import
(
dbapi
,
types
,
userfunctions
,
py25tests
,
factory
,
transactions
,
hooks
,
regression
)
factory
,
transactions
,
hooks
,
regression
,
dump
)
def
test_main
():
run_unittest
(
dbapi
.
suite
(),
types
.
suite
(),
userfunctions
.
suite
(),
py25tests
.
suite
(),
factory
.
suite
(),
transactions
.
suite
(),
hooks
.
suite
(),
regression
.
suite
())
hooks
.
suite
(),
regression
.
suite
()
,
dump
.
suite
()
)
if
__name__
==
"__main__"
:
test_main
()
Misc/ACKS
Dosyayı görüntüle @
b9803421
...
...
@@ -362,6 +362,7 @@ Lawrence Kesteloot
Vivek Khera
Mads Kiilerich
Taek Joo Kim
Paul Kippes
Steve Kirsch
Ron Klatchko
Bastian Kleineidam
...
...
Misc/NEWS
Dosyayı görüntüle @
b9803421
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
Core and builtins
-----------------
- Patch #2426: Added sqlite3.Connection.iterdump method to allow easy dumping
of databases. Contributed by Paul Kippes at PyCon 2008.
- Patch #2477: Added from __future__ import unicode_literals.
- Added backport of bytearray type.
...
...
Modules/_sqlite/connection.c
Dosyayı görüntüle @
b9803421
...
...
@@ -1199,6 +1199,52 @@ finally:
return
retval
;
}
/* Function author: Paul Kippes <kippesp@gmail.com>
* Class method of Connection to call the Python function _iterdump
* of the sqlite3 module.
*/
static
PyObject
*
pysqlite_connection_iterdump
(
pysqlite_Connection
*
self
,
PyObject
*
args
)
{
PyObject
*
retval
=
NULL
;
PyObject
*
module
=
NULL
;
PyObject
*
module_dict
;
PyObject
*
pyfn_iterdump
;
if
(
!
pysqlite_check_connection
(
self
))
{
goto
finally
;
}
module
=
PyImport_ImportModule
(
MODULE_NAME
".dump"
);
if
(
!
module
)
{
goto
finally
;
}
module_dict
=
PyModule_GetDict
(
module
);
if
(
!
module_dict
)
{
goto
finally
;
}
pyfn_iterdump
=
PyDict_GetItemString
(
module_dict
,
"_iterdump"
);
if
(
!
pyfn_iterdump
)
{
PyErr_SetString
(
pysqlite_OperationalError
,
"Failed to obtain _iterdump() reference"
);
goto
finally
;
}
args
=
PyTuple_New
(
1
);
if
(
!
args
)
{
goto
finally
;
}
Py_INCREF
(
self
);
PyTuple_SetItem
(
args
,
0
,
(
PyObject
*
)
self
);
retval
=
PyObject_CallObject
(
pyfn_iterdump
,
args
);
finally:
Py_XDECREF
(
args
);
Py_XDECREF
(
module
);
return
retval
;
}
static
PyObject
*
pysqlite_connection_create_collation
(
pysqlite_Connection
*
self
,
PyObject
*
args
)
{
...
...
@@ -1344,6 +1390,8 @@ static PyMethodDef connection_methods[] = {
PyDoc_STR
(
"Creates a collation function. Non-standard."
)},
{
"interrupt"
,
(
PyCFunction
)
pysqlite_connection_interrupt
,
METH_NOARGS
,
PyDoc_STR
(
"Abort any pending database operation. Non-standard."
)},
{
"iterdump"
,
(
PyCFunction
)
pysqlite_connection_iterdump
,
METH_NOARGS
,
PyDoc_STR
(
"Returns iterator to the dump of the database in an SQL text format."
)},
{
"__enter__"
,
(
PyCFunction
)
pysqlite_connection_enter
,
METH_NOARGS
,
PyDoc_STR
(
"For context manager. Non-standard."
)},
{
"__exit__"
,
(
PyCFunction
)
pysqlite_connection_exit
,
METH_VARARGS
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment