{"id":8295,"date":"2023-02-10T00:19:18","date_gmt":"2023-02-09T23:19:18","guid":{"rendered":"https:\/\/smartdatamodels.org\/?page_id=8295"},"modified":"2023-02-10T00:20:17","modified_gmt":"2023-02-09T23:20:17","slug":"pysmartdatamodels-code-example","status":"publish","type":"page","link":"https:\/\/smartdatamodels.org\/index.php\/pysmartdatamodels-code-example\/","title":{"rendered":"pysmartdatamodels code example"},"content":{"rendered":"<p><code>from pysmartdatamodels import pysmartdatamodels as sdm<br \/>\nsubject = \"dataModel.Weather\"<br \/>\ndataModel = \"WeatherForecast\"<br \/>\nattribute = \"precipitation\"<br \/>\nprint(sdm.load_all_datamodels())<br \/>\nprint(len(sdm.load_all_attributes())) # there is more than 19.000 to get all listed<br \/>\nprint(sdm.list_all_datamodels())<br \/>\nprint(sdm.list_all_subjects())<br \/>\nprint(sdm.datamodels_subject(\"dataModel.Weather\"))<br \/>\nprint(sdm.description_attribute(subject, dataModel, attribute))<br \/>\nprint(sdm.datatype_attribute(subject, dataModel, attribute))<br \/>\nprint(sdm.model_attribute(subject, dataModel, attribute))<br \/>\nprint(sdm.units_attribute(subject, dataModel, attribute))<br \/>\nprint(sdm.attributes_datamodel(subject, dataModel))<br \/>\nprint(sdm.subject_repolink(subject))<br \/>\nprint(sdm.datamodel_repolink(dataModel))<br \/>\nprint(sdm.print_datamodel(subject, dataModel, \",\", [ \"property\", \"type\", \"dataModel\", \"repoName\", \"description\", \"typeNGSI\", \"modelTags\", \"format\", \"units\", \"model\", ]))<br \/>\nsdm.update_data()<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>from pysmartdatamodels import pysmartdatamodels as sdm subject = &#8220;dataModel.Weather&#8221; dataModel = &#8220;WeatherForecast&#8221; attribute = &#8220;precipitation&#8221; print(sdm.load_all_datamodels()) print(len(sdm.load_all_attributes())) # there is more than 19.000 to get all listed print(sdm.list_all_datamodels()) print(sdm.list_all_subjects()) print(sdm.datamodels_subject(&#8220;dataModel.Weather&#8221;)) print(sdm.description_attribute(subject, dataModel, attribute)) print(sdm.datatype_attribute(subject, dataModel, attribute)) print(sdm.model_attribute(subject, dataModel, attribute)) print(sdm.units_attribute(subject, dataModel, attribute)) print(sdm.attributes_datamodel(subject, dataModel)) print(sdm.subject_repolink(subject)) print(sdm.datamodel_repolink(dataModel)) print(sdm.print_datamodel(subject, dataModel, &#8220;,&#8221;, [&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/smartdatamodels.org\/index.php\/pysmartdatamodels-code-example\/\">More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-8295","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":8287,"url":"https:\/\/smartdatamodels.org\/index.php\/pysmatdatamodels-documentation\/","url_meta":{"origin":8295,"position":0},"title":"pysmartdatamodels documentation","author":"maestro","date":"10\/02\/2023","format":false,"excerpt":"1- Load all datamodels in a dict like the official list. Function load_all_datamodels() Returns a dict with all data models with this object structure - repoName: The name of the subject - repoLink: the link to the repository of the subject - dataModels: An array with all the datamodels of\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6408,"url":"https:\/\/smartdatamodels.org\/index.php\/export-of-database-of-attributes-of-the-smart-data-models\/","url_meta":{"origin":8295,"position":1},"title":"Export of database of attributes of the Smart Data Models","author":"maestro","date":"21\/07\/2022","format":false,"excerpt":"For some developers is interesting to access the database of attributes you can search in the main menu -> Search You have it in this link https:\/\/smartdatamodels.org\/extra\/smartdatamodels.json the file (It is a large one). It has a CC-BY license so feel free to use it and we will be happy\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":570,"url":"https:\/\/smartdatamodels.org\/index.php\/subject-alert-datamodel-alert\/","url_meta":{"origin":8295,"position":2},"title":"Subject-Alert-DataModel-alert","author":"maestro","date":"12\/08\/2020","format":false,"excerpt":"Page for the discussion and evolution of the smart data model alert of the Subject AlertData Model Schema and Examples of the payloadsDescriptions of the main properties of the data model Property Description subCategory Any of the different groups of subcategories defined, including Natural Disaster, Health, Security, Traffic, Environemental, Agricultural\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11182,"url":"https:\/\/smartdatamodels.org\/index.php\/contribute-with-an-spreadsheet\/","url_meta":{"origin":8295,"position":3},"title":"Contribute with a spreadsheet","author":"maestro","date":"07\/11\/2024","format":false,"excerpt":"","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":909,"url":"https:\/\/smartdatamodels.org\/index.php\/create-automatically-the-specification-of-your-data-model\/","url_meta":{"origin":8295,"position":4},"title":"Create automatically the specification of your data model","author":"maestro","date":"02\/12\/2020","format":false,"excerpt":"The new version of the smart data models specification is on progress (most of the \/doc directories of the data models have a version). If you want to check how this would look like you can have through this API call Call: https:\/\/smartdatamodels.org\/extra\/create_spec.php Parameters: (Mandatories) dataModel: The name of the\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":925,"url":"https:\/\/smartdatamodels.org\/index.php\/create-a-draft-spec-of-your-data-model\/","url_meta":{"origin":8295,"position":5},"title":"Create a draft spec of your data model","author":"maestro","date":"04\/12\/2020","format":false,"excerpt":"In order to create an example of the data model that you are going to contribute this call helps you to create a spec. this is the API call If you want to check how this would look like you can have through this API call Call: https:\/\/smartdatamodels.org\/extra\/create_spec.php Parameters: (Mandatories)\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/pages\/8295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/comments?post=8295"}],"version-history":[{"count":2,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/pages\/8295\/revisions"}],"predecessor-version":[{"id":8297,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/pages\/8295\/revisions\/8297"}],"wp:attachment":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/media?parent=8295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}