我被我的剧本困住了.我需要比较两个数组,一个是查询的结果,另一个是文件的内容:
$Array1 = Invoke-Sqlcmd -Query "select name from person"
$Array2 = Get-Content ".\Myfile.txt" #the file is a set of one item
every line
Run Code Online (Sandbox Code Playgroud)
现在,在$ Array2中,有些项目我想从$ Array1中删除.
我怎样才能做到这一点?谢谢你的帮助!
我正在开发一个小应用程序,我可以在其中显示我的数据库中的所有表(sqlite3),并选择其中一个,可视化数据(我知道我可以使用管理员,但我需要在应用程序中这样做)
我的model.py中有不同的模型,比如myModel1,myModel2 ......
在我的views.py中
def myhomepage(request):
tables_list = connection.introspection.table_names()
return render(request, 'myhomepage.html', { 'tables_list': tables_list})
def detail_table(request, table):
try:
Table_to_View = ContentType.objects.get(app_label="myapp", model=table)
except Table_to_View.DoesNotExist:
raise Http404 ("La tabella non esiste")
context = {'Table_to_View' : Table_to_View }
return render(request, "detail_table.html", context )
Run Code Online (Sandbox Code Playgroud)
和模板myhomepage.html
{#something#}
<title>Lista delle tabelle</title>
<body>
{% if tables_list %}
<ul>
{%for t in tables_list %}
<li> <a href="{% url 'detail_table' t %}"> {{table}}</a></li>
{% endfor %}
</ul>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
这是urls.py
from django.conf.urls import url
from . …Run Code Online (Sandbox Code Playgroud)