Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
39a16dd2
Kaydet (Commit)
39a16dd2
authored
Kas 01, 2015
tarafından
José Tomás Tocino
Kaydeden (comit)
Tim Graham
Mar 18, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25658 -- Allowed inspectdb to inspect a specific set of tables.
üst
f15f4b8b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
3 deletions
+28
-3
AUTHORS
AUTHORS
+1
-0
inspectdb.py
django/core/management/commands/inspectdb.py
+5
-1
django-admin.txt
docs/ref/django-admin.txt
+8
-2
1.10.txt
docs/releases/1.10.txt
+3
-0
tests.py
tests/inspectdb/tests.py
+11
-0
No files found.
AUTHORS
Dosyayı görüntüle @
39a16dd2
...
@@ -373,6 +373,7 @@ answer newbie questions, and generally made Django that much better:
...
@@ -373,6 +373,7 @@ answer newbie questions, and generally made Django that much better:
Jordan Dimov <s3x3y1@gmail.com>
Jordan Dimov <s3x3y1@gmail.com>
Jorge Bastida <me@jorgebastida.com>
Jorge Bastida <me@jorgebastida.com>
Jorge Gajon <gajon@gajon.org>
Jorge Gajon <gajon@gajon.org>
José Tomás Tocino García <josetomas.tocino@gmail.com>
Joseph Kocherhans <joseph@jkocherhans.com>
Joseph Kocherhans <joseph@jkocherhans.com>
Josh Smeaton <josh.smeaton@gmail.com>
Josh Smeaton <josh.smeaton@gmail.com>
Joshua Ginsberg <jag@flowtheory.net>
Joshua Ginsberg <jag@flowtheory.net>
...
...
django/core/management/commands/inspectdb.py
Dosyayı görüntüle @
39a16dd2
...
@@ -17,6 +17,8 @@ class Command(BaseCommand):
...
@@ -17,6 +17,8 @@ class Command(BaseCommand):
db_module
=
'django.db'
db_module
=
'django.db'
def
add_arguments
(
self
,
parser
):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'table'
,
action
=
'store'
,
nargs
=
'*'
,
type
=
str
,
help
=
'Selects what tables or views should be introspected.'
)
parser
.
add_argument
(
'--database'
,
action
=
'store'
,
dest
=
'database'
,
parser
.
add_argument
(
'--database'
,
action
=
'store'
,
dest
=
'database'
,
default
=
DEFAULT_DB_ALIAS
,
help
=
'Nominates a database to '
default
=
DEFAULT_DB_ALIAS
,
help
=
'Nominates a database to '
'introspect. Defaults to using the "default" database.'
)
'introspect. Defaults to using the "default" database.'
)
...
@@ -54,7 +56,9 @@ class Command(BaseCommand):
...
@@ -54,7 +56,9 @@ class Command(BaseCommand):
yield
''
yield
''
yield
'from
%
s import models'
%
self
.
db_module
yield
'from
%
s import models'
%
self
.
db_module
known_models
=
[]
known_models
=
[]
for
table_name
in
connection
.
introspection
.
table_names
(
cursor
):
tables_to_introspect
=
options
[
'table'
]
or
connection
.
introspection
.
table_names
(
cursor
)
for
table_name
in
tables_to_introspect
:
if
table_name_filter
is
not
None
and
callable
(
table_name_filter
):
if
table_name_filter
is
not
None
and
callable
(
table_name_filter
):
if
not
table_name_filter
(
table_name
):
if
not
table_name_filter
(
table_name
):
continue
continue
...
...
docs/ref/django-admin.txt
Dosyayı görüntüle @
39a16dd2
...
@@ -354,11 +354,12 @@ Specifies the database to flush. Defaults to ``default``.
...
@@ -354,11 +354,12 @@ Specifies the database to flush. Defaults to ``default``.
``inspectdb``
``inspectdb``
-------------
-------------
.. django-admin:: inspectdb
.. django-admin:: inspectdb
[table [table ...]]
Introspects the database tables in the database pointed-to by the
Introspects the database tables in the database pointed-to by the
:setting:`NAME` setting and outputs a Django model module (a ``models.py``
:setting:`NAME` setting and outputs a Django model module (a ``models.py``
file) to standard output.
file) to standard output. You may choose what tables to inspect by passing
their names as arguments.
Use this if you have a legacy database with which you'd like to use Django.
Use this if you have a legacy database with which you'd like to use Django.
The script will inspect the database and create a model for each table within
The script will inspect the database and create a model for each table within
...
@@ -406,6 +407,11 @@ table's lifecycle, you'll need to change the
...
@@ -406,6 +407,11 @@ table's lifecycle, you'll need to change the
:attr:`~django.db.models.Options.managed` option to ``True`` (or simply remove
:attr:`~django.db.models.Options.managed` option to ``True`` (or simply remove
it because ``True`` is its default value).
it because ``True`` is its default value).
.. versionadded:: 1.10
Support for the ``table`` argument(s) to choose what tables should be
inspected was added.
.. django-admin-option:: --database DATABASE
.. django-admin-option:: --database DATABASE
Specifies the database to introspect. Defaults to ``default``.
Specifies the database to introspect. Defaults to ``default``.
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
39a16dd2
...
@@ -292,6 +292,9 @@ Management Commands
...
@@ -292,6 +292,9 @@ Management Commands
* The :djadmin:`shell` command supports tab completion on systems using
* The :djadmin:`shell` command supports tab completion on systems using
``libedit``, e.g. Mac OSX.
``libedit``, e.g. Mac OSX.
* The :djadmin:`inspectdb` command lets you choose what tables should be
inspected by specifying their names as arguments.
Migrations
Migrations
~~~~~~~~~~
~~~~~~~~~~
...
...
tests/inspectdb/tests.py
Dosyayı görüntüle @
39a16dd2
...
@@ -28,6 +28,17 @@ class InspectDBTestCase(TestCase):
...
@@ -28,6 +28,17 @@ class InspectDBTestCase(TestCase):
# inspected
# inspected
self
.
assertNotIn
(
"class DjangoContentType(models.Model):"
,
out
.
getvalue
(),
msg
=
error_message
)
self
.
assertNotIn
(
"class DjangoContentType(models.Model):"
,
out
.
getvalue
(),
msg
=
error_message
)
def
test_table_option
(
self
):
"""
inspectdb can inspect a subset of tables by passing the table names as
arguments.
"""
out
=
StringIO
()
call_command
(
'inspectdb'
,
'inspectdb_people'
,
stdout
=
out
)
output
=
out
.
getvalue
()
self
.
assertIn
(
'class InspectdbPeople(models.Model):'
,
output
)
self
.
assertNotIn
(
"InspectdbPeopledata"
,
output
)
def
make_field_type_asserter
(
self
):
def
make_field_type_asserter
(
self
):
"""Call inspectdb and return a function to validate a field type in its output"""
"""Call inspectdb and return a function to validate a field type in its output"""
out
=
StringIO
()
out
=
StringIO
()
...
...
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