import sys
from ruamel.std.pathlib import Path
from ruamel.yaml import YAML, version_info
yaml = YAML(typ='safe', pure=True)
yaml.default_flow_style = False
def my_compose_document(self):
self.parser.get_event()
node = self.compose_node(None, None)
self.parser.get_event()
return node
yaml.Composer.compose_document = my_compose_document
def yaml_include(loader, node):
y = loader.loader
yaml = YAML(typ=y.typ, pure=y.pure)
yaml.composer.anchors = loader.composer.anchors
return yaml.load(Path(node.value))
yaml.Constructor.add_constructor("!include", yaml_include)
data = yaml.load(Path('warehouse.yaml'))
yaml.dump(data, sys.stdout)
specific:
spec1:
<<: *obj1
spec2:
<<: *obj1
key1: 10
warehouse:
obj1: &obj1
key1: 1
key2: 2
specific: !include specific.yaml
JNIEXPORT jstring JNICALL Java_Test_saySomething(JNIEnv *env, jobject obj, jstring jStr) {
// Получаем указатель на массив символов String
const char *cStr = (*env)->GetStringUTFChars(env, jStr, NULL);
if (cStr == NULL) return NULL;
// Выводим полученное
printf("%s\n", cStr);
// Освобождаем выделенную под строку область памяти
(*env)->ReleaseStringUTFChars(env, jStr, cStr);
// Получаем новый массив символов от пользователя
char buf[128];
scanf("%s", buf);
// Преобразовываем массив символов в String
return (*env)->NewStringUTF(env, buf);
}
The above class introduces the ForeignKey construct, which is a directive applied to Column that indicates that values in this column should be constrained to be values present in the named remote column. This is a core feature of relational databases, and is the “glue” that transforms an otherwise unconnected collection of tables to have rich overlapping relationships. The ForeignKey above expresses that values in the addresses.user_id column should be constrained to those values in the users.id column, i.e. its primary key.
A second directive, known as relationship(), tells the ORM that the Address class itself should be linked to the User class, using the attribute Address.user. relationship() uses the foreign key relationships between the two tables to determine the nature of this linkage, determining that Address.user will be many to one. An additional relationship() directive is placed on the User mapped class under the attribute User.addresses. In both relationship() directives, the parameter relationship.back_populates is assigned to refer to the complementary attribute names; by doing so, each relationship() can make intelligent decision about the same relationship as expressed in reverse; on one side, Address.user refers to a User instance, and on the other side, User.addresses refers to a list of Address instances.
python manage.py collectstatic
. Во-вторых,<div class="container">
<h1>Создайте новую запись:</h1>
<br>
<form enctype="multipart/form-data" method="post">
{{ form.media }}
{% csrf_token %}
<p>{{ form.title }}</p>
<p>{{ form.text }}</p>
<button type="submit">Отправить</button>
</form>
</div>
from psycopg2.extras import Json
data = [
{'a': 1},
{'b': 2},
{'c': 3, 'z': None}
]
curs.execute("insert into mytable (jsondata) values (%s)", [Json(data)])