Django test — Model object created but cannot be found










0















I'm calling a Model which is called People and do



People.objects.create(first='foo', last='bar', bio='test')


This Model uses db_table='"people"."background"'



When I run the test, doing People.objects.first() finds something, but doing raw query like SELECT * from people.background gives me nothing. Why is that?










share|improve this question

















  • 2





    Tests run on a different database, typically with a test_ prefix iirc.

    – Willem Van Onsem
    Nov 14 '18 at 19:30











  • @WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

    – JChao
    Nov 14 '18 at 19:34















0















I'm calling a Model which is called People and do



People.objects.create(first='foo', last='bar', bio='test')


This Model uses db_table='"people"."background"'



When I run the test, doing People.objects.first() finds something, but doing raw query like SELECT * from people.background gives me nothing. Why is that?










share|improve this question

















  • 2





    Tests run on a different database, typically with a test_ prefix iirc.

    – Willem Van Onsem
    Nov 14 '18 at 19:30











  • @WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

    – JChao
    Nov 14 '18 at 19:34













0












0








0








I'm calling a Model which is called People and do



People.objects.create(first='foo', last='bar', bio='test')


This Model uses db_table='"people"."background"'



When I run the test, doing People.objects.first() finds something, but doing raw query like SELECT * from people.background gives me nothing. Why is that?










share|improve this question














I'm calling a Model which is called People and do



People.objects.create(first='foo', last='bar', bio='test')


This Model uses db_table='"people"."background"'



When I run the test, doing People.objects.first() finds something, but doing raw query like SELECT * from people.background gives me nothing. Why is that?







django unit-testing django-models






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 19:28









JChaoJChao

452623




452623







  • 2





    Tests run on a different database, typically with a test_ prefix iirc.

    – Willem Van Onsem
    Nov 14 '18 at 19:30











  • @WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

    – JChao
    Nov 14 '18 at 19:34












  • 2





    Tests run on a different database, typically with a test_ prefix iirc.

    – Willem Van Onsem
    Nov 14 '18 at 19:30











  • @WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

    – JChao
    Nov 14 '18 at 19:34







2




2





Tests run on a different database, typically with a test_ prefix iirc.

– Willem Van Onsem
Nov 14 '18 at 19:30





Tests run on a different database, typically with a test_ prefix iirc.

– Willem Van Onsem
Nov 14 '18 at 19:30













@WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

– JChao
Nov 14 '18 at 19:34





@WillemVanOnsem I'm aware of that. The table people.background is correctly created, and checking the description of the Model does show that db_table should be people.background. It should be connecting to the right database as far as I believe, but I cannot locate the created data......

– JChao
Nov 14 '18 at 19:34












1 Answer
1






active

oldest

votes


















0














Apparently Django doesn't officially support schema.



I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,



with connection().cursor as cursor:
cursor.execute("""INSERT INTO bleh bleh bleh""") # assuming there's autocommit


EDIT:



Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307497%2fdjango-test-model-object-created-but-cannot-be-found%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Apparently Django doesn't officially support schema.



    I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,



    with connection().cursor as cursor:
    cursor.execute("""INSERT INTO bleh bleh bleh""") # assuming there's autocommit


    EDIT:



    Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.






    share|improve this answer



























      0














      Apparently Django doesn't officially support schema.



      I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,



      with connection().cursor as cursor:
      cursor.execute("""INSERT INTO bleh bleh bleh""") # assuming there's autocommit


      EDIT:



      Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.






      share|improve this answer

























        0












        0








        0







        Apparently Django doesn't officially support schema.



        I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,



        with connection().cursor as cursor:
        cursor.execute("""INSERT INTO bleh bleh bleh""") # assuming there's autocommit


        EDIT:



        Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.






        share|improve this answer













        Apparently Django doesn't officially support schema.



        I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,



        with connection().cursor as cursor:
        cursor.execute("""INSERT INTO bleh bleh bleh""") # assuming there's autocommit


        EDIT:



        Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 14:36









        JChaoJChao

        452623




        452623





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307497%2fdjango-test-model-object-created-but-cannot-be-found%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            Evgeni Malkin